Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: removing spaces from a file name



On 30/01/2008, d.henman <dhenman@xxxxxxxxx> wrote:
>
> I found that I also had to add code to translate Japanese encoded spaces in the following way.  This is a two byte code 0x81 0x40.  I just built a script to remove the ascii and Japanese space codes as follows:
>
>   sed -b -e s/' '/_/g  $TEMP_FILE  >$TEMP_FILE1
>   mv $TEMP_FILE1   $TEMP_FILE
>   sed -b -e s/`echo -n "\x81\x40"`/_/g  $TEMP_FILE  >$TEMP_FILE1
>   mv $TEMP_FILE1    $TEMP_FILE
>
> It could be made prettier, but it works as is and I left it.
>
> The point is that there may be other space characters than 0x20 in European languages, or it this covered in zsh?

I don't think spaces except the 0x20 one are as big a problem since
they don't cause trouble with word splitting. And it looks like your
script is about editing files, not renaming them?

(you can simplify your script by giving two -e switches to one sed
call, or one regex with a | in it. if you're using gnu sed you can
further simplify it with the -i switch.)

-- 
Mikael Magnusson



Messages sorted by: Reverse Date, Date, Thread, Author