Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Append to Filename 1

Status
Not open for further replies.

cwsstins

MIS
Aug 10, 2004
412
US
I'm trying to take a txt file and "mv" it to a XML file, adding the date prior to the extension. I've got variables to display the date in the correct format. The original filename will will be "ccs45_?.txt" where ? can be any one or two-digit number.
Code:
filename=ccs45_[0-9]

mv $DATA_DIR/$filename.txt $DATA_DIR/${filename}_$y$m$d.xml

This code moves this ccs45_1.txt into this ccs45_[0-9]_061120.xml

How can I keep the original filename intact (up to the extension) when moved into the filename with the date.newextension?
 
Something like this ?
for f in `ls $DATA_DIR/ccs45_[0-9]*.txt`
do mv $f $DATA_DIR/`basename $f .txt`_$y$m$d.xml
done

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top