shell scripts and escaped charecters in file names
mdff
nospam at mgedv.net
Sun Jan 15 03:12:57 PST 2006
<SNIP>
>
> Hello,
> I am trying to get the following script to run with no success.
> - ------------------------------------
> #!/bin/csh
> foreach file (\*vol\*)
> mv $file `basename $file .par2`.PAR2
> echo $file
> end
> - ------------------------------------
> and get the following error:
> usage: mv [-f | -i | -n] [-v] source target
> ~ mv [-f | -i | -n] [-v] source ... directory
>
> I know it is because of the spaces and such in the file names. I have
> tried quoting single double and also escaping them but all fails. what
> is the magic? Please cc me off list. thanks!
>
<SNIP>
try the following:
ls -1|grep '\.par2$'|while read s_line
do
mv -i "./$s_line" "./`basename $s_line .par2`.PAR2"
done;
the "./" stuff is for files starting with "-";
br...
More information about the freebsd-questions
mailing list