need script to copy all files containing a certain string to a directory
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Yes what zulfilee provided would be the best choice I presume. Sorry for my bad code. I typed it of my head using windows, never tried it though. It was just an idea...
This is what I like about Linux and shell scripting. With so many different yet similar commands, you can write a script with the same output in many different ways... You have a couple of them here already.
actually, the code in the first post from marghorp worked fine -on os x at least.
now, my new problem is how to make this work on a folder of 10,000 text files without getting the 'Argument list too long." our mail server throws the backup of all outgoing mails for all users into one folder and i need a way to restore for just one user.
this script works great, but i have to split up the folder first.
sorry, i don't know the exact reason, but i was told that the reason i get the 'Argument list too long error' is because i'm searching through too many files.
the script works fine if i run it on a directory with (a lot) fewer files in it.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.