LinuxAnswers - the LQ Linux tutorial section.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


Search this Thread
Old 04-28-2005, 06:50 PM   #1
Registered: Feb 2003
Distribution: Suse 8.1
Posts: 102

Rep: Reputation: 15
search and copy multiple files


I have a list of filenames in a text file.

I'd like a way to be able to search a filesystem and have it export to another location all files that match the file names.

Each filename is stored on a separate line in the text file.

Is there an easy way to do this?

TIA for any pointer....I'm at my wits end here...

Old 04-28-2005, 10:06 PM   #2
Senior Member
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 56
Here's an example which may get you started.

auto login.txt
capture gdm screen.txt
desktop icons.txt
file split.txt

orig_dir="/mnt/tech/aclinux/Linux Technical Docs"

cat $file | \
while read i ; do
find "$orig_dir" -type f -name "$i" -exec cp {} "$dest_dir" \;
Old 04-29-2005, 04:40 AM   #3
Senior Member
Registered: Mar 2004
Location: england
Distribution: FreeBSD, Debian, Mint, Puppy
Posts: 3,290

Rep: Reputation: 174Reputation: 174
This will work, but will copy directory structure too
if a filename is a path

cat  list.txt  | cpio -pd  /blah/blah/here


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I copy multiple files Leary664 Linux - General 18 09-06-2005 02:58 AM
search special files and copy in directory. abhi Linux - Newbie 2 04-10-2005 09:22 AM
Search and Replace over multiple files The_Nerd Linux - Software 8 06-20-2004 06:59 AM
find and copy files into multiple directories avargas22 Linux - Newbie 2 04-01-2004 11:11 AM
copy multiple files into one file HelpPlease Programming 2 12-09-2003 02:36 PM

All times are GMT -5. The time now is 07:02 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration