find command/pipe type question - Unix

This is a discussion on find command/pipe type question - Unix ; 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 ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: find command/pipe type question

  1. find command/pipe type question


    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 | 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 {} \;


  2. Re: find command/pipe type question

    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 | 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

  3. Re: find command/pipe type question

    In article ,
    Michael Tosch wrote:

    > 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 | file

    >
    > 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 ***

  4. Re: find command/pipe type question


    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 ?


+ Reply to Thread