![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Recursively copy only specific files from a directory tree | sharpsharkrocks | Shell Programming and Scripting | 3 | 01-07-2008 02:16 PM |
| Copy files from a directory by ftp | hippa77 | UNIX for Dummies Questions & Answers | 3 | 10-06-2007 03:26 PM |
| Copy files from one directory to another | HAA | Shell Programming and Scripting | 1 | 07-06-2006 03:47 AM |
| Copy files from one directory to another | hd2006 | Shell Programming and Scripting | 0 | 06-07-2006 03:29 PM |
| copy files from one directory to another directory | zip_zip | UNIX for Dummies Questions & Answers | 5 | 09-14-2003 07:16 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Read from fileList.txt, copy files from directory tree
Hi, hopefully this is a fairly simple Q&A.
I have a clean file list of approximately 180 filenames with no directory or slashes in front of the filename nor any extension or dot ".". I would like to read from this list, find these files recursively down through directory trees, copy the files and place the copies(with the original filenames intact) in an archive or copy directory that is user defined, perhaps through a user prompt at the beginning of the script. Thanks! ![]() |
|
||||
|
Code:
# $1 is the command line parameter = path to store the file
# the search for the files starts from the current working directory
# assume the filenamess in the list can occur more than once
while read file
do
let i=1
find . -name "$file" |
while read sourcefile
do
cp "$sourcefile" "$1"/"$file"_$i
let i=$i+1
done
done < list_of_filenames
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|