LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-04-2013, 07:20 PM   #1
bcyork
LQ Newbie
 
Registered: Dec 2010
Location: Chicago, IL
Distribution: Linux Mint 11 / Debian 6
Posts: 29

Rep: Reputation: 1
Copying from unknown directory


I have a huge directory that I need to copy random files from. The directory tree is pretty elaborate. Is it possible to do a cp from any directory as long as the variables are matched. Currently I have been just guessing how many directories deep the file it is by doing

cp -r */*/*/*/*file-24* /destination/

I know the exact file name but not the location.

Thanks for the help.
 
Old 06-04-2013, 07:30 PM   #2
jlinkels
Senior Member
 
Registered: Oct 2003
Location: Bonaire
Distribution: Debian Wheezy/Jessie/Sid, Linux Mint DE
Posts: 4,493

Rep: Reputation: 635Reputation: 635Reputation: 635Reputation: 635Reputation: 635Reputation: 635
Code:
find . -name "thefilename" -exec cp -v {} /path/to/destination/. \;
Untested. But it copies one file at a time so it seems pretty harmless. Unless you have multiple files with the same name with different contents.

jlinkels
 
Old 06-04-2013, 08:08 PM   #3
bcyork
LQ Newbie
 
Registered: Dec 2010
Location: Chicago, IL
Distribution: Linux Mint 11 / Debian 6
Posts: 29

Original Poster
Rep: Reputation: 1
Worked perfectly! Thanks jlinkels that is a life saver
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Difference after copying large directory to a new directory mazhar07 Linux - Server 4 04-04-2010 03:46 AM
Copying a single file into each directory of a directory tree mlapl1 Linux - Newbie 2 06-27-2007 11:18 PM
Copying a Directory into Another Directory with Subdirectories oadvantage Linux - Newbie 4 03-06-2006 06:27 PM
Automatically Copying files from the ftp directory into the html directory swatward Linux - General 3 04-17-2005 11:55 PM
Copying etc directory njschroe SUSE / openSUSE 6 12-15-2004 02:45 AM


All times are GMT -5. The time now is 10:48 AM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration