The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
xargs problem encrypted Shell Programming and Scripting 3 05-16-2009 12:15 PM
why we use xargs.. kripssmart Shell Programming and Scripting 3 06-18-2008 12:02 AM
Question concerning xargs cp27316 UNIX for Dummies Questions & Answers 4 03-13-2007 11:30 PM
Help with xargs JimJim UNIX for Dummies Questions & Answers 4 02-08-2005 07:08 PM
xargs jpprial UNIX for Dummies Questions & Answers 4 09-17-2001 08:29 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-06-2009
santosh1234 santosh1234 is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 16
explain Xargs ?

hi all ,
i am using the following command :
find . -type f | xargs grep <pattern>
can u explain me what is the importance of xargs here ?
  #2 (permalink)  
Old 01-07-2009
otheus's Avatar
otheus otheus is offline Forum Staff  
Moderator ala Mode
  
 

Join Date: Feb 2007
Location: Innsbruck, Austria
Posts: 1,864
xargs runs the specified arguments as a command, followed by the filenames provided from standard input. If the length of a command line exceeds UNIX's capability, it runs the command again with the remaining arguments (and repeats until all arguments are consumed).

The reason you do this instead of: find . -type f -exec grep ... is because (1) you don't have to mess with the funny {} syntax and (2) it's more efficient -- fewer invocations of grep, and (3) when grep receives multiple arguments on the command line, it preceeds each match with the filename, so that you know which file grep found it in. (You can do this with find, but it's a hack).
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 10:47 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0