I have a file name FSR350B050112.dly. That is how it comes to me in UNIX. I need to strip off the 050112 to make the file just say FSR350B.dly and then I will do some other manipulation from there but I just do not know how to get that piece off.
To rename all the files in the current directory (ksh like):
for dly in *.dly; do
case "$dly" in *[0-9][0-9][0-9][0-9][0-9][0-9].dly)
mv "$dly" $(echo "$dly" | sed 's!......\.dly!.dly!')
esac
done
Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
PHV....when I use your lines of code...only the last files changes. I do have several files that need to be changed to that format but only the last on is actually changing?? Can you help??
Ok.....one more question and I think I will be out of ya'lls hair. I used the command `echo $fname | sed -e 's/^\(.*\)\(......\)\.dly$/\1.dly/g'` to take care of the first issue. Now I need to use that same command along the same lines to get rid of the date plus everything else to the right of it. As in FSR350B050112.dly needs to be just FSR350B so I can then add a different piece to the end of it. Thank you for all of the help.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.