Difference between using xargs and backticks


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Difference between using xargs and backticks
# 1  
Old 12-14-2010
Difference between using xargs and backticks

Hey all. Just a fast question, what is the technical difference between using back ticks and using xargs to perform a command?

Here's an example
Code:
Find /mydir -name *.conf |xargs rm

Vs

Rm 'find /mydir -name *.conf'

Is there a performance hit? I know they do the same thing but which is better to use in practice?
# 2  
Old 12-14-2010
Of course xargs supports large filecounts, but putting that difference aside there would be extra overhead in loading and executing the xargs binary to start with, but this should be fairly minor unless your doing the same thing many times.

With GUN xargs you also get support for files with spaces in their names (via -0 parameter and -print0 in find). You can also suppress the run if the argument list is empty (via -r parameter).
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Nesting backticks

I'm trying to make a dialog window that prints the output of grep that takes the output of find. Unfortunately my nested backticks don't work. Here is the dialog window: dialog --stdout --title "test" --backtitle "test" --msgbox "Test:\n `grep -l "${tablica}" `find $string``" 16 60I think I... (2 Replies)
Discussion started by: Starting_Leaf
2 Replies

2. Shell Programming and Scripting

Difference b/w xargs and "-exec" in Find

Hi, What is the difference between the following commands find . -type f -exec grep 'abc' {} \; and find . -type f | xargs grep 'abc' Appreciate your help. (2 Replies)
Discussion started by: bobbygsk
2 Replies

3. Shell Programming and Scripting

SSH and Backticks [solved]

I have been testing a new script and cannot figure out why my `cat spath` will not execute on the remote machine? sudo ssh -p 22344 -o "PasswordAuthentication no" -o "HostbasedAuthentication yes" -l testuser 192.168.1.6 "find `cat spath` -depth" cat: spath: No such file or directory but... (0 Replies)
Discussion started by: metallica1973
0 Replies

4. Programming

difference bewteen pipe, xargs, and exec

I have read several docs on these on the web and looked at examples. I can't figure out the difference. In some cases you use one or the other or you combine them. can someone help me understand this? (1 Reply)
Discussion started by: guessingo
1 Replies

5. Shell Programming and Scripting

Am I abusing backticks?

I'm always concerned I might be abusing backticks within my scripts. A current script I'm writing has this for example: stripscriptname=`echo $scriptname | sed 's/\(.*\)\..*/\1/'` stripsearch=`echo $searchpattern | tr -d ' ,/'` Both of these variables are set inside the script (in fact,... (2 Replies)
Discussion started by: mglenney
2 Replies

6. AIX

Difference in Using xargs

Hi , Can somebody explain what is the difference in the below commands.. when using Xargs its giving all the hidden files and is it something xargs will do recursive searching or parsing ? find . -type f -links 1 | xargs ls -li find . -type f -links 1 | ls -li (1 Reply)
Discussion started by: Karthikeyan K
1 Replies

7. UNIX for Dummies Questions & Answers

sed: removing backticks from certain lines

Hi, I would like to change some lines in my mysql-dump, because there a syntax problems with some version of mysql. I 'd like to change USE ´someDatabase´; to USE someDatabase; (without backticks) using the sed command in the shell Thanks & best regards Bernd (5 Replies)
Discussion started by: bjb
5 Replies

8. Shell Programming and Scripting

Backticks within backticks?

Hi, I'm trying to do something like this: range= `expr `date '+%m'` - 1` and it does not work. How can I tell it to evaluate an expression within another expression evaluation? I was at first worried that `date '+%m'` would return a string but apparently expr does the math okay normally, so the... (3 Replies)
Discussion started by: jeriryan87
3 Replies

9. Shell Programming and Scripting

Perl - backticks v system in if statements

Can someone explain the difference between backticks and system when evaluated in these if statements: sub getDate { print "start date\n"; if ( system("/bin/date") ) { print "can't get date\n"; exit(2); } print "finish date\n"; } Returns the following: start date Thu... (5 Replies)
Discussion started by: gjkeenan
5 Replies

10. UNIX for Dummies Questions & Answers

Difference between xargs and exec

Hi, I have tried both the options in small dummy scripts, but somehow i can't differentiate between the two. find . -name H* -exec ls -l {} \; find . -name H* | xargs ls -l Both work the ditto way. Any help is appreciated. (19 Replies)
Discussion started by: vibhor_agarwali
19 Replies
Login or Register to Ask a Question