|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
xargs vs. pipe
I have been using unix on and off for a number of years. I am not a sys admin. I use what I need. I have googled this, but I really can't figure out what is the difference between using xarg and just using a regular pipe? Why do I need to include xarg sometimes and how do I know when I need it?
|
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
You would use xargs when you get an errror message like "too many arguments", or when you want on the same line the output of more than one command, look : Code:
ant:/home/vbe $ date pwd date: bad conversion ant:/home/vbe $ date;pwd Fri May 4 16:32:42 METDST 2012 /home/vbe ant:/home/vbe $ (date;pwd)|xargs Fri May 4 16:33:04 METDST 2012 /home/vbe ant:/home/vbe $ |
| Sponsored Links | ||
|
|
#3
|
||||
|
||||
|
pipes connect output of one command to input of another. xargs is used to build commands. so if a command needs argument passed instead of input on stdin you use xargs... the default command is echo (vbe's example). it breaks spaces and newlines and i avoid it for this reason when working with files. Code:
$ printf '%s\n' file1 file2 file3 | xargs touch $ ls file? file1 file2 file3 |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| difference bewteen pipe, xargs, and exec | guessingo | Programming | 1 | 10-12-2011 12:28 PM |
| Display find results, and pipe to xargs | mij | Shell Programming and Scripting | 4 | 06-19-2011 07:31 PM |
| Replace pipe with Broken Pipe | saj | Shell Programming and Scripting | 1 | 04-08-2011 09:18 AM |
| Pipe to "xargs rm" : filename with spaces | coolatt | Shell Programming and Scripting | 3 | 02-10-2010 06:32 AM |
| Removing a filename which has special characters passed from a pipe with xargs | jerardfjay | AIX | 3 | 05-19-2009 01:01 PM |
|
|