LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 11-26-2011, 01:08 AM   #1
j-jock
LQ Newbie
 
Registered: Dec 2007
Posts: 6

Rep: Reputation: 0
Using terminal command -Find files in a folder and copy them to a different folder


I have used the find command for many simple tasks, but I have a problem that is beyond my level of expertise.
I have folders that contain a large number of folders which are all of the same construction.
AB123-22-33 - Name Lastname - Title
AB234-22-33 - Name Lastname - Title
AB567-22-33 - Name Lastname - Title

What I need to do, is to ignore AB123-22-33 - and find and list all the files that start with Foo (Lastname), so that I can move them into another folder.

Or better yet, I need to find all the files that start with Foo, and move those files to another folder with the one command
Any help would be appreciated
Bob
 
Old 11-26-2011, 02:29 AM   #2
rob.rice
Senior Member
 
Registered: Apr 2004
Distribution: slack what ever
Posts: 1,076

Rep: Reputation: 205Reputation: 205Reputation: 205
"mv foo* /another_place"
* is a wild card that matches any thing it also works like this *(lastname)*
 
Old 11-26-2011, 11:40 PM   #3
j-jock
LQ Newbie
 
Registered: Dec 2007
Posts: 6

Original Poster
Rep: Reputation: 0
Thanks, I was able to solve the problem last night. I used:
find /home/music/ -iname "*foo*" -exec mv '{}'
 
Old 11-27-2011, 09:43 AM   #4
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
Glad you got it working. You should, however, still familiarize yourself with the full power of your shell's globbing features.

glob
exended globbing

And please use [code][/code] tags around your code, to preserve formatting and to improve readability.

Last edited by David the H.; 11-27-2011 at 09:46 AM. Reason: fixed url
 
Old 11-28-2011, 02:20 AM   #5
j-jock
LQ Newbie
 
Registered: Dec 2007
Posts: 6

Original Poster
Rep: Reputation: 0
[SOLVED] Using terminal command -Find files in a folder and copy them to a different folder

Thanks,
I had a look at the two globbing pages and will definately be going back to look at them again. My problem is, that I end up going for long stretches without using BASH, and have time to forget all the more sophisticated commands.
Bob
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Scripts to list folder contents and copy images from folder and subfolders brunces Linux - Newbie 6 11-03-2011 01:23 PM
i need to copy files from one folder to another folder using shell anurupr Linux - Newbie 17 03-04-2010 09:07 AM
want to copy an inode folder from acdrom to a home directory (folder). nhbob Linux - Newbie 8 12-20-2009 11:12 AM
Find files and copy the results to desired folder? colbert Linux - Newbie 6 11-08-2008 11:21 PM
folder copy command bobb_roof Linux - Newbie 4 11-04-2006 04:59 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:59 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
Open Source Consulting | Domain Registration