Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 06-04-2013, 06:20 PM   #1
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, 06:30 PM   #2
Senior Member
Registered: Oct 2003
Location: Bonaire
Distribution: Debian Wheezy/Jessie/Stretch/Sid, Linux Mint DE
Posts: 4,606

Rep: Reputation: 686Reputation: 686Reputation: 686Reputation: 686Reputation: 686Reputation: 686
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.

Old 06-04-2013, 07:08 PM   #3
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


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 02:46 AM
Copying a single file into each directory of a directory tree mlapl1 Linux - Newbie 2 06-27-2007 10:18 PM
Copying a Directory into Another Directory with Subdirectories oadvantage Linux - Newbie 4 03-06-2006 05:27 PM
Automatically Copying files from the ftp directory into the html directory swatward Linux - General 3 04-17-2005 10:55 PM
Copying etc directory njschroe SUSE / openSUSE 6 12-15-2004 01:45 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:51 AM.

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