LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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, 02: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, 03:29 AM   #2
rob.rice
Senior Member
 
Registered: Apr 2004
Distribution: slack what ever
Posts: 1,007

Rep: Reputation: 168Reputation: 168
"mv foo* /another_place"
* is a wild card that matches any thing it also works like this *(lastname)*
 
Old 11-27-2011, 12:40 AM   #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, 10:43 AM   #4
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian + kde 4 / 5
Posts: 6,834

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
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 10:46 AM. Reason: fixed url
 
Old 11-28-2011, 03: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


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 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 02:23 PM
i need to copy files from one folder to another folder using shell anurupr Linux - Newbie 17 03-04-2010 10:07 AM
want to copy an inode folder from acdrom to a home directory (folder). nhbob Linux - Newbie 8 12-20-2009 12:12 PM
Find files and copy the results to desired folder? colbert Linux - Newbie 6 11-09-2008 12:21 AM
folder copy command bobb_roof Linux - Newbie 4 11-04-2006 05:59 PM

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

All times are GMT -5. The time now is 12:38 PM.

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