Christopher, I didn't know that I could use sed-like substitutions with bash variables! Neat little tool! I checked and it doesn't work for ksh or sh however ;-< I would suggest, just to be safe, adding a -d option to the ls command like this: ls -d *SNG* | while read name; do new=${name/.SNG.txt/.txt} mv $name $new done Without this option, if there is a *SNG* that is a directory you may get very unsatisfactory results. Grant Q -----Original Message----- From: Christopher Mahmood [mailto:ckm@suse.com] Sent: Tuesday, June 17, 2003 2:59 PM To: SuSE List Subject: Re: [SLE] Shell script query * James Ogley (james@usr-local-bin.org) [030617 14:48]:
filename.SNG.txt
(don't ask - long story...)
Now, filename is a random sequence of between 5 and eight numeric characters.
My question is this:
Does anyone know of a way in bash script to rename all the files of the above format to filename.txt?
Something like ls *SNG* | while read name; do new=${name/.SNG.txt/.txt} mv $name $new done -- -ckm -- Check the headers for your unsubscription address For additional commands send e-mail to suse-linux-e-help@suse.com Also check the archives at http://lists.suse.com Please read the FAQs: suse-linux-e-faq@suse.com