Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Blog | Linux Links | Bling | About BLU

BLU Discuss list archive


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

simple bash script question



matthew nicholson wrote:
> and i have a another command : 
> 
> cat list2 | while read line; do line2=${line//\(/}; line3=${line2//\)/};
> fline=${line//\ /\\ };fline3=${fline//\(/\\\(};fline4=${fline3//\)/\\
> \)}; fline2=${line3//\ /\\ }; echo "mv $fline4 $fline2"; mv -v $fline4
> $fline2; done;
> ... 
> 
> however, everytime i run this, mv, with every file, says:
> 
> mv: invalid option -- \
> Try `mv --help' for more information.
> 
> BUT, i can copy the output of the command (it spits out the exact
> command being exectued every time mv is called) and paste it into the
> terminal, and, wham, it works. so, the syntax of what i'm passing to mv
> is, from what i can tell, correct.

The problem is you're using escaping mechanisms that are needed for the
shell's parser to determine what constitutes a single string, but when
you're invoking the command like "mv $fline4..." you've effectively done
that work for the parser, and that step gets skipped.  So basically, you
need to ensure that the string you end up with as the value of $fline4
has no '\' characters in it (just like the string that the parser builds
and actually passes to the 'mv' command).

That's a gnarly enough command line that you're on your own to figure
out exactly how to go about that though...

Good luck.
--Matt




BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org