Scripting names from a file

Paul Howarth paul at city-fan.org
Tue Sep 28 15:04:11 UTC 2004


Chadley Wilson wrote:
> OK Maybe I am trying to be too clever in my simplification of the senario, so 
> maybe this helps:
> I have a directory with files in it, I also have a text file with a list of 
> certian files, I need to mv the files listed in the text files out of the dir 
> into a new dir which I have created.
> Does that make more sense?
> 
> So basically I am after something like this
> for i in `each_name_in_file ` ; do
> mv $1 /dest/dir
> done
> 
> 
> The bit I can't workout is `each_name_in_file `

for i in `cat file_with_filenames`; do
	mv $i /dest/dir
done

This may break if the filenames have unusual characters in them, like shell 
metacharacters or spaces.

Paul.




More information about the fedora-list mailing list