Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Find file that contains "....." (command in Unix)

by Abigail-II (Bishop)
on Mar 28, 2003 at 09:49 UTC ( [id://246439]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Find file that contains "....." (command in Unix)
in thread Find file that contains "....." (command in Unix)

Good solution, but you could run into trouble if the resulting command line is bigger than the maximum size supported by the OS.

Of course, you will only run into trouble if your xargs is broken. The point of using xargs is to avoid the problem you are describing.

The disadvantage of using -exec is that find will spawn a grep process for each file found, while with the use of xargs, far less processes will be spawned.

Abigail

  • Comment on Re: Find file that contains "....." (command in Unix)

Replies are listed 'Best First'.
Re: Re: Find file that contains "....." (command in Unix)
by bronto (Priest) on Mar 28, 2003 at 10:09 UTC
    Of course, you will only run into trouble if your xargs is broken. The point of using xargs is to avoid the problem you are describing.

    ++Abigail-II. The fact was not mentioned on my Linux' xargs man page. But it was on Solaris':

         The generated command line length will be  the  sum  of  the
         size  in bytes of the utility name and each argument treated
         as strings, including a null byte  terminator  for  each  of
         these strings. The xargs utility will limit the command line
         length such that when the command line is invoked, the  com-
         bined   argument  and  environment  lists  will  not  exceed
         {ARG_MAX}-2048 bytes. Within this constraint, if neither the
         -n  nor the -s option is specified, the default command line
         length will be at least {LINE_MAX}.
    

    Not very clear, indeed. But one can go by abstraction :-) and suppose that the line length limit will be circumvented!

    Thanks, I learnt something new!

    Ciao!
    --bronto


    The very nature of Perl to be like natural language--inconsistant and full of dwim and special cases--makes it impossible to know it all without simply memorizing the documentation (which is not complete or totally correct anyway).
    --John M. Dlugosz

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://246439]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (3)
As of 2024-04-19 02:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found