cp a file to named date
so I have a log that spits out lines in the form of
Transferring file `1MIN_TEST01.mov'
and i wish to have only
the Base File Name
and finally i wish to have that log named the date
so if today is jan 30 2013 - 013013.txt
here is what i have
### this is a xample line from log:: Transferring file `1MIN_TEST01.mov'
#h="Transferring file `1MIN_TEST01.mov'"
sed 's/Transferring file//g' ~/\log/\f_h_logfilea.txt > ~/\log/\f_h_logfile4a.txt
sed "s/\`//g" ~/\log/\f_h_logfile4a.txt > ~/\log/\f_h_logfile4b.txt
sed "s/'//g" ~/\log/\f_h_logfile4b.txt > ~/\log/\f_h_logfile4c.txt
sed "s/ //g" ~/\log/\f_h_logfile4c.txt > ~/\log/\f_h_logfilefin.txt
##cp ~/\log/\f_h_logfilefin.txt ~/\log/\f_h_logfilefin.txt+`date +%m%d%y`
cp ~/\log/\f_h_logfilefin.txt ~/\log/\$d.txt
now this will echo
but the file that is cp'ed is named $d.txt
I am ever so confused how
echo $d can be 013013 ( provided the day is jan 30 2013
and the file name is literal $d.txt
any help is appreciated.
also -- likely there is a better means of sed ..
i just keep running it through and cleaning it up
my thinking was those 'versions'
just get over written and i have a tidy 013013.txt
If you intend to add code tags manually, place them with  and not <>, ie: [CODE]...[/CODE].
Also, it is better to use the $HOME env var instead of the ~ when referring your home directory within a script. This ensures it gets expanded correctly.
These can be replaced with (I've used the , as my delimiter):
After running the above sed command, simply move the log file to the new name:
1st thanks for the note about code tags...
and opps on me ... i ahve just seen how one may ( # gadget in interface ) mark code.
yep that works
thanks for the word about use of $HOME , did not know that one
and I see the sed is working as
sed -i "s,Transferring file \`\(.*\)',\1,"
I struggle to understand it part by part .
what is the ,1, doing?
also I may need additionally to sed OUT
Making directory `trashbox'
I love this community -
Hope I've explained it properly so you can sed out the other stuff.
I offer High Thanks for your Lucid and detailed explanation.:hattip:
To your credit - i understand , i grow.
If ever in cincinnati - I am buying yall a beverage of choice.:)
that matter of
\1 - Replace the old pattern with the first back-reference (remembered pattern),
i never read that in any of my investigation nor the matter of
as back-references in RegEx. sed remembers whatever pattern is inside the brackets.
The best part about being shown - is it enables one to learn more on one's own.
using the , as my delimiter, is now my personal preference as well
|All times are GMT -5. The time now is 10:34 PM.|