Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
TetraWiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Linux 101 hacks
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=='''Hack 22. Xargs Command'''== xargs is a very powerful command that takes output of a command and pass it as argument of another command. Following are some practical examples on how to use xargs effectively. 1. When you are trying to delete too many files using rm, you may get error message: /bin/rm Argument list too long β Linux. Use xargs to avoid this problem. find ~ -name β*.logβ -print0 | xargs -0 rm -f 2. Get a list of all the *.conf file under /etc/. There are different ways to get the same result. Following example is only to demonstrate the use of xargs. The output of the find command in this example is passed to the ls βl one by one using xargs. # ## find /etc -name "*.conf" | xargs ls βl # If you have a file with list of URLs that you would like to download, you can use xargs as shown below. # ## cat url-list.txt | xargs wget βc # Find out all the jpg images and archive it. # ## find / -name *.jpg -type f -print | xargs tar -cvzf images.tar.gz # Copy all the images to an external hard-drive. # ## ls *.jpg | xargs -n1 -i cp {} /external-hard-drive/directory
Summary:
Please note that all contributions to TetraWiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
TetraWiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)