LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

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

Rep: Reputation: 15
search and copy multiple files


Hello,

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...

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

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

/home/list.txt
Code:
auto login.txt
capture gdm screen.txt
clamscan.txt
desktop icons.txt
file split.txt
Code:
#!/bin/bash

file="/home/list.txt"
orig_dir="/mnt/tech/aclinux/Linux Technical Docs"
dest_dir="/home/images"

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

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

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


Reply


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
Trackbacks are Off
Pingbacks are On
Refbacks are 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 03:18 PM.

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