Home » Questions » Computers [ Ask a new question ]

xargs vs backtick

xargs vs backtick

More silly questions from the Linux n00b. =D

Asked by: Guest | Views: 115
Total answers/comments: 2
Guest [Entry]

"Backticks hurt when dealing with more complex scripting; you need to carefully escape backticks contents. Because of that I often change them into $(...).

xargs might call rm multiple times in your example if there is lots of files -- POSIX systems can have upper limit on length of command parameters.

xargs has other features that backticks doesn't: f.e. xargs can take parameters separated by \0 byte to deal with filenames with spaces."
Guest [Entry]

"If the program supports multiple arguments in that order, the backticks should perform identically. Since not all programs support multiple arguments like that, the problem arises when a command in backticks is executed and returns multiple results. If you know the latter command will work, use it. If you aren't sure, stick with using xargs to be safe. find also has a useful -exec switch which can be used like so:

find / -type f -exec grep -i word {} +

where the braces are replaced with the current file match from find."