Tim Allen on 16 Oct 2008 09:00:42 -0700


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] CLI for "find" text string in an unknown file


As a side note, if you end up with a directory with too many files in it for “ls” or “rm” to handle, this is a handy syntax to remember. This has happened to me a few times in the past with uploadable image directories that have gotten bigger than I ever expected.

 

Example, to delete a bunch of files from such a directory (don’t try this at home if you’re not sure of what you’re doing!):

 

find ./* | xargs rm

 

Another trick I use to automatically compress uploaded images (requires ImageMagick) that our field technicians failed to use an automated program to resize / compress:

 

find ./ -size "+200k" | xargs mogrify -quality 60 -geometry 600x10000

 

It is a very handy syntax to know and understand.

 

Regards,

 

-Tim

 


From: plug-bounces@lists.phillylinux.org [mailto:plug-bounces@lists.phillylinux.org] On Behalf Of Andrew Gwozdziewycz
Sent: Thursday, October 16, 2008 11:45 AM
To: Philadelphia Linux User's Group Discussion List
Subject: Re: [PLUG] CLI for "find" text string in an unknown file

 

 

On Wed, Oct 15, 2008 at 7:53 PM, Dan Widyono <dan@widyono.net> wrote:

> find <directory> -exec grep -l <string> {} \;

Or with only one tool, grep -rl <string> /path/to/top/directory


Or.. using xargs to avoid the crazy syntax of using -exec

find <directory> | xargs grep <string>



--
Andrew Gwozdziewycz
apgwoz@gmail.com
http://www.apgwoz.com  | http://www.photub.com

___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug