Re: find in conjuction with grep

From: Kevin Wang (rightsock_at_gmail.com)
Date: 08/12/04

  • Next message: Bill Tetens: "Re: Cannot install FC2"
    Date: Thu, 12 Aug 2004 14:51:42 -0700
    To: For users of Fedora Core releases <fedora-list@redhat.com>
    
    

    two issues - security and performance. performance was covered
    already. explicitly, xargs can be 100x or more faster.

    The security issue I don't remember being explicitly covered.

    find . -exec grep "string" {}

    what happens when you have a filename with a space in it?
    quotes?
    double quotes?

    xargs suffers from the same issues, that's why there's the -print0 arg
    for find and -0 arg for xargs - \0 terminated strings are guaranteed,
    as nulls are one of the only invalid filename characters.

    sure, 99% of the time it isn't a problem, but when you're writing
    scripts that run as root that are running on a multi user system
    (think thousands of college students with too much time on their hands
    just wanting to break in and read everyone else's email)

       - Kevin

    On Thu, 12 Aug 2004 22:10:37 +0200, Alexander Dalloz
    <alexander.dalloz@uni-bielefeld.de> wrote:
    > Am Do, den 12.08.2004 schrieb Lew Bloch um 21:08:
    >
    > > >>I've been using
    > > >>> find . -exec grep "phrase I want" {} \;
    > > >
    > > > Not the best way. Using -exec is problematic.
    > >
    > > How exactly is the -exec directive problematic?
    > >
    > > I use "find ... -exec grep ..." a lot. I also use the "find ... | xargs
    > > grep ..." a lot.
    >
    > Please see the thread discussion. It is already answered.
    >
    > Alexander
    >
    > --
    > Alexander Dalloz | Enger, Germany | GPG key 1024D/ED695653 1999-07-13
    > Fedora GNU/Linux Core 2 (Tettnang) kernel 2.6.7-1.494.2.2smp
    > Serendipity 22:09:55 up 8 days, 15:37, load average: 1.27, 1.23, 1.27
    >
    >
    >

    -- 
    fedora-list mailing list
    fedora-list@redhat.com
    To unsubscribe: http://www.redhat.com/mailman/listinfo/fedora-list
    

  • Next message: Bill Tetens: "Re: Cannot install FC2"

    Relevant Pages

    • Re: find in conjuction with grep
      ... xargs can be 100x or more faster. ... | The security issue I don't remember being explicitly covered. ... passing the filename to grep. ... A larger issue is that you're doing things as root without knowing how ...
      (Fedora)
    • Re: sh: line 1: /bin/cp: Argument list too long
      ... separated list of arguments where the single and double quotes ... and the backslash serve as escaping each other. ... you don't need xargs to pipe the output of find into ... as find does have the feature that breaks a list of arguments to ...
      (comp.unix.admin)
    • Re: sh: line 1: /bin/cp: Argument list too long
      ... with xargs expected input format (unless you post process find ... Some man pages for xargs claim that the string "" gets ... separated list of arguments where the single and double quotes ... output is just newline separated list of file paths. ...
      (comp.unix.admin)
    • Re: [opensuse] Another Bash scripting question
      ... 17 May 2008 23:30:51 Randall R Schulz wrote: ... The way you're using xargs is essentially a no-op here, ... if you put the action code into a separately executable script ... for arg; do ...
      (SuSE)
    • Re: find | xargs | grep over filenames with spaces
      ... in the GNU versions of find and xargs, ... then wraps the entire pathname in double quotes. ... (which not all xargs implementations do IIRC). ...
      (comp.unix.shell)