Networking Forums

Networking Forums > Computer Networking > Linux Networking > Copy files using filenames from text files with shell script or bash script

Reply
Thread Tools Display Modes

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

 
 
altariamx2003@gmail.com
Guest
Posts: n/a

 
      11-19-2006, 11:01 PM
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

 
Reply With Quote
 
 
 
 
David M
Guest
Posts: n/a

 
      11-19-2006, 11:43 PM
On Sun, 19 Nov 2006 16:01:42 -0800, (E-Mail Removed) rearranged
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

 
Reply With Quote
 
C.J. Steele
Guest
Posts: n/a

 
      11-20-2006, 02:35 AM
for f in `cat lisa.txt`; do cp $f /dst/dir; done

-C

On Nov 19, 6:43 pm, David M <NOS...@nospam.com> wrote:
> On Sun, 19 Nov 2006 16:01:42 -0800, altariamx2...@gmail.com rearranged
> 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


 
Reply With Quote
 
Jiri Slaby
Guest
Posts: n/a

 
      11-20-2006, 07:35 PM
C.J. Steele wrote:
> 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
 
Reply With Quote
 
Jarmo Pussinen
Guest
Posts: n/a

 
      11-23-2006, 08:27 AM
Jiri Slaby kirjoitti:

> C.J. Steele wrote:
> > 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

 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
shell script to log http request newbiegalore Linux Networking 0 04-06-2008 11:05 PM
executing ssh from shell script R C V Linux Networking 2 03-23-2008 07:20 PM
executing ssh from shell script R C V Linux Networking 3 03-19-2008 07:53 PM
Bash script to see if PPP link is up... Gabriel Michael Linux Networking 34 09-14-2003 03:55 PM
Bash script via inetd = no joy tylernt Linux Networking 10 09-05-2003 08:53 PM



1 2 3 4 5 6 7 8 9 10 11