Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 15 Jan 2006 12:12:56 +0100
From:      "mdff" <nospam@mgedv.net>
To:        <freebsd-questions@freebsd.org>
Cc:        'Ronny Hippler' <r11roadster@yahoo.com>
Subject:   RE: shell scripts and escaped charecters in file names 
Message-ID:  <007101c619c4$a3585f40$0a86a8c0@avalon.lan>
In-Reply-To: <43C9FB5A.2050506@yahoo.com>

next in thread | previous in thread | raw e-mail | index | archive | help
<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...




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?007101c619c4$a3585f40$0a86a8c0>