[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: echo/sed combination inserts extra characters



Jesus Arocho wrote:
I want to rename a series of photo files downloaded from a camera; the intent is to append the date to the beginning of the file name. The relevant lines are:

newdir=`date +%F | sed 's/-//g'` #newdir used to make the directory and to rename the files.

new=Í„`echo $i | sed -e 's/_//'` # strip the current file name of the underline in the middle dsc_0001.jpg to dsc0001.jpg

mv -f $i $newdir'_'$new  #rename the current file

The resulting file name may contain an extraneous character (does not print) located just after the _ ; as if the echo/sed combination had added a character.

Did you try "echo -n"?



Reply to: