Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Source data holding many files for 'move' cmd in Unix Script

Status
Not open for further replies.

jrcpierce

Technical User
Nov 1, 2001
1
0
0
CA
I would like to execute a 'mv' cmd in a Unix script with the source data being a file containing the names of the files I want to move.

&quot;mv <sourcefile ./destdir&quot; does not work.

Does anyone know how to read a file containing source filenames into a move command. I'd appreciate any assistance.
 
How about this ...

[tt]
#!/bin/sh
for F in `cat sourcefile`
do
mv $F destdir
done
[/tt]

where sourcefile is the name of the file with the filenames,
and destdir is the name of the destination directory TandA

One by one, the penguins steal my sanity.
 
.. and of course the standard disclaimer applies when using mv or rm ...

Be Careful :)

Greg.
 
Hmm - that brings back memories ...

You only do rm -r * without checking what directory you're in when running as root once :-0

(I wondered why it was taking so long ... |-I - fortunately the server hadn't gone live, or I'd have been in REAL trouble X-) : Anyway, it was a good test of our backup procedures LOL) TandA

One by one, the penguins steal my sanity.
 
&quot;You only do rm -r * without checking what directory you're in when running as root once&quot;

I wish..... Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top