The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-30-2007
fxvisions fxvisions is offline
Registered User
  
 

Join Date: Mar 2007
Posts: 8
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!
  #2 (permalink)  
Old 10-30-2007
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,811

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

Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On




All times are GMT -4. The time now is 02:17 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0