Unix questions - find command/pipe type question

This is Interesting: Free IT Magazines  
Home > Archive > Unix questions > October 2005 > find command/pipe type question





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author find command/pipe type question
surfunbear@yahoo.com

2005-10-26, 6:01 pm


Here is a question, suppose I wanted to delete all executable binary
files greater than about 1 meg with just 1 command from the command
line.

Going down this route I can get as far as this, but not sure what next:

file `find . -size +2000 -print` | grep executable


I can't pipe to file command as in <cmd> | file
so that seems out.


not sure about this route, I get an error, pipe inside a -exec ?


find . -size +2000 -exec file | grep executable {} \;

Michael Tosch

2005-10-26, 6:01 pm

surfunbear@yahoo.com wrote:
> Here is a question, suppose I wanted to delete all executable binary
> files greater than about 1 meg with just 1 command from the command
> line.
>
> Going down this route I can get as far as this, but not sure what next:
>
> file `find . -size +2000 -print` | grep executable
>
>
> I can't pipe to file command as in <cmd> | file


xargs converts the pipe into arguments:

find . -size +2000 -print | xargs file | grep executable

but can run into a system limit.

> so that seems out.
>
>
> not sure about this route, I get an error, pipe inside a -exec ?
>
>
> find . -size +2000 -exec file | grep executable {} \;
>


find . -size +2000 -exec file {} \; | grep executable

is what you are looking for.
Some systems allow a faster method:

find . -size +2000 -exec file {} + | grep executable


--
Michael Tosch @ hp : com
Bill Marcum

2005-10-27, 2:48 am

On 26 Oct 2005 14:28:16 -0700, surfunbear@yahoo.com
<surfunbear@yahoo.com> wrote:
>
> Here is a question, suppose I wanted to delete all executable binary
> files greater than about 1 meg with just 1 command from the command
> line.
>
> Going down this route I can get as far as this, but not sure what next:
>
> file `find . -size +2000 -print` | grep executable
>
>
> I can't pipe to file command as in <cmd> | file
> so that seems out.
>

man find. Use the -perm option and "-type f" to find executable files.


--
Incumbent, n.:
Person of liveliest interest to the outcumbents.
-- Ambrose Bierce, "The Devil's Dictionary"
Barry Margolin

2005-10-27, 2:48 am

In article <djou89$a4g$1@aken.eed.ericsson.se>,
Michael Tosch <eedmit@NO.eed.SPAM.ericsson.PLS.se> wrote:

> surfunbear@yahoo.com wrote:
>
> xargs converts the pipe into arguments:
>
> find . -size +2000 -print | xargs file | grep executable
>
> but can run into a system limit.


No, xargs exists to *avoid* the system limit that occurs when you use
the backtick method.

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
surfunbear@yahoo.com

2005-10-28, 4:53 pm


Thanks for all the help I like that xargs.

How can I limit find from going down some directory paths and ignoring
others, is there any easy way ?

Bill Marcum

2005-10-28, 4:53 pm

On 27 Oct 2005 07:31:50 -0700, surfunbear@yahoo.com
<surfunbear@yahoo.com> wrote:
>
> Thanks for all the help I like that xargs.
>
> How can I limit find from going down some directory paths and ignoring
> others, is there any easy way ?
>

-prune


--
A figure with curves always offers a lot of interesting angles.
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com