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

Re: mv multiple files w/wildcard



Lance Hoffmeyer <lanceh@ibm.net> writes:

> I have a number of subdirectories where I have files with - such as 
> name - title.txt and I wish to convert them to:
> name: title.txt
> 
> In bash I tried:
> 
> for i in *-*;do mv $i `echo $i | sed -e 's/ - /:/'`'done 
                                                     ^
                                              This should be a ';'.

You have to quote the filenames, if they contain white spaces.

The following, for example, works:

for name in *-*; do
  new_name=$(echo $name | sed -e 's/\ -\ /: /;'); mv "$name" "$new_name"
done

	moritz
-- 
/* Moritz Schulte <moritz@hp9001.fh-bielefeld.de>
 * http://hp9001.fh-bielefeld.de/~moritz/
 * PGP-Key available, encrypted Mail is welcome.
 */



Reply to: