Home » RDBMS Server » Server Administration » Oracle-Unix commands: Pipe operator and xargs command.
Oracle-Unix commands: Pipe operator and xargs command. [message #60219] Sun, 25 January 2004 23:18 Go to next message
Patrick Tahiri
Messages: 119
Registered: January 2004
Senior Member
Hi,

I would like to know what is the difference between the pipe operator and the xargs command?!

xargs command is used to pipe a list to another command but so does the pipe (&#124) operator?

Many thanks for your help!

Regards,

Patrick Tahiri.
Re: Oracle-Unix commands: Pipe operator and xargs command. [message #60224 is a reply to message #60219] Mon, 26 January 2004 06:16 Go to previous messageGo to next message
Thiru
Messages: 1089
Registered: May 2002
Senior Member
Hi
pipe and xargs serve different functions.
pipe simply passes in the o/p of one command as i/p to the 2nd command(ie o/p one program becomes the i/p of the subsequent program through the pipe).

xargs ,on the other hand,constructs an argument list based on the o/p of the 1st command, that can be used on the 2nd command.

Both are used in conjunction. For eg)

dbatest@samgdeab06:/ora1/oracle>ls test*
test      test.out  test.sql  test.tar

# Here sort takes in the o/p of the preceeding command and acts on it to give us the sorted o/p. This happens becos of the pipe

dbatest@samgdeab06:/ora1/oracle>ls test*&#124sort
test
test.out
test.sql
test.tar

# In the following example, ls cannot take in the i/p from it's standard in. So it just lists out the whole directory, irrespective of the standard i/p.

dbatest@samgdeab06:/ora1/oracle>ls test*&#124ls
1                          doc                        oui                        test.out
NOT                        dsmerror.log               product                    test.sql
afiedt.buf                 email                      spcpkg.lis                 test.tar
app                        findExec                   spctab.lis                 tmp
daily_checklist_space.log  jre                        spcusr.lis
dbadmin                    ls.out                     sppurge.lis
dead.letter                oraInventory               test

# This is where xargs serves us. As you see below,xargs takes the standard i/p, constructs an arguement list and passes that as 'arguements' to the 'ls' command. And 'ls' works on those arguments and gives us the result.

dbatest@samgdeab06:/ora1/oracle>ls test*&#124xargs ls
test      test.out  test.sql  test.tar

 
# As seen below, when used with -i option, xargs replaces {} with the i/p arguements. the test* files are moved to the directory TEST

dbatest@samgdeab06:/ora1/oracle>ls test*&#124xargs -i mv {} TEST
dbatest@samgdeab06:/ora1/oracle>ls TEST
test      test.out  test.sql  test.tar



-Thiru
Re: Oracle-Unix commands: Pipe operator and xargs command. [message #60232 is a reply to message #60224] Mon, 26 January 2004 21:42 Go to previous message
Patrick Tahiri
Messages: 119
Registered: January 2004
Senior Member
Thank you so much!!
It is now clear how it works!!

Best regards,

Patrick Tahiri.
Previous Topic: Table and View performance
Next Topic: How to prune Alert Log file & Background Trace Files? (UNIX system)
Goto Forum:
  


Current Time: Fri Sep 20 10:20:59 CDT 2024