Re: echo/sed combination inserts extra characters
Jesus Arocho <jesus_arocho@comcast.net> writes:
> 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
^<<== there is an extra character
> 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. The processing continues because the loop is selecting all jpg or
> nef files, but trying to do something with the file from the command line
> results in file not found. I can see the extra character in konqueror.
This is a little late, and several other people already have made
suggestions, but my system does show an extra character. I don't know
if it was accidentally added when you transfered it into your message,
but you might want to check for the character between the 'new=' and
the backquote. It is barely visible to me, and it looks like it would
be just after the underscore as you reported, so maybe that is it.
I checked, and the 'unicode' command reports the character is:
U+0344 COMBINING GREEK DIALYTIKA TONOS
UTF-8: cd 84 UTF-16BE: 0344 Decimal: ̈́
̈́
Category: Mn (Mark, Non-Spacing)
Bidi: NSM (Non-Spacing Mark)
Combining: 230 (Above)
Decomposition: 0308 0301
--
Carl Johnson carlj@peak.org
Reply to: