Copy files using filenames from text files with shell script or bash script

Copy files using filenames from text files with shell script or bash script

Post by altariamx2.. » Tue, 21 Nov 2006 09:01:42



How can I do this????

I have the file "lista.txt", and this file have the next information:
     one.txt
     two.txt
     five.txt
    six.txt
-------------------
This files exist in the same directory that "list.txt", I would like to
copy this files to other directory

Using Windows the batch file would be like this:  for /f "tokens=*" %i
in (list.txt) do copy "%i" destdir\

How can I do something like that in REDHAT??

Best Regards

 
 
 

Copy files using filenames from text files with shell script or bash script

Post by C.J. Steel » Tue, 21 Nov 2006 12:35:06


for f in `cat lisa.txt`; do cp $f /dst/dir; done

-C



> some electrons to form:

> > How can I do this????http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html

> --
> David M  (dmacchiarolo)http://home.triad.rr.com/redsled
> T/S 53
> sled351 Linux 2.4.18-14  has been up 3 days 15:04


 
 
 

Copy files using filenames from text files with shell script or bash script

Post by Jiri Slab » Wed, 22 Nov 2006 05:35:50



> for f in `cat lisa.txt`; do cp $f /dst/dir; done

Not a good way if you have filenames with whitespaces in lista.txt.

--
js

 
 
 

Copy files using filenames from text files with shell script or bash script

Post by Jarmo Pussine » Fri, 24 Nov 2006 18:27:05


Jiri Slaby kirjoitti:


> > for f in `cat lisa.txt`; do cp $f /dst/dir; done

> Not a good way if you have filenames with whitespaces in lista.txt.

How about
# while read f ; do cp "$f" "/dst/dir" ; done < list.txt