w3reference home
Linux Commands Tutorial


Bookmark and Share

xargs

xargs [options] [command]

Execute command (with any initial arguments), but read remaining arguments from standard input instead of specifying them directly. xargs passes these arguments in several bundles to command, allowing command to process more arguments than it could normally handle at once. The arguments are typically a long list of filenames (generated by ls or find, for example) that get passed to xargs via a pipe.

Options
-0, --null Expect filenames to be terminated by NULL instead of whitespace. Do not treat quotes or backslashes specially.
--e[string] , -E [string] , --eof[=string] Set EOF to _ or, if specified, to string.
--help Print a summary of the options to xargs and then exit.
-i[string] , -I [string] , --replace[=string] Replace all occurrences of { }, or string, with the names read from standard input. Unquoted blanks are not considered argument terminators. Implies -x and -L 1.
-l[lines] , -L [lines] , --max-lines[=lines] Allow no more than lines nonblank input lines on the command line (default is 1). Implies -x.
-n args, --max-args=args Allow no more than args arguments on the command line. Overridden by the maximum number of characters set with -s.
-p, --interactive Prompt for confirmation before running each command line. Implies -t.
-P max, --max-procs=max Allow no more than max processes to run at once. The default is 1. A maximum of 0 allows as many as possible to run at once.
-r, --no-run-if-empty Do not run command if standard input contains only blanks.
-s max, --max-chars=max Allow no more than max characters per command line.
-t, --verbose Verbose mode. Print command line on standard error before executing.
-x, --exit If the maximum size (as specified by -s) is exceeded, exit.
--version Print the version number of xargs and then exit.


Examples
grep for pattern in all files on the system:
  • find / | xargs grep pattern > out &
    Run diff on file pairs (e.g., f1.a and f1.b, f2.a and f2.b, etc.):
  • echo $* | xargs -n2 diff
    The previous line would be invoked as a shell script, specifying filenames as arguments. Display file, one word per line (same as deroff -w):
  • cat file | xargs -n1
    Move files in olddir to newdir, showing each command:
  • ls olddir | xargs -i -t mv olddir/{ } newdir/{ }
  • Code Validator
    Learn FTP
    Color finder
    Link Checker
    Free web designs
    Coming soon!
    Interview Questions...
    'w3reference : Learn by examples ... Advanced to beginner's tutorials ...'
    Ajax: AJAX tutorial1 | Apache: Apache HTTP Server | Restarting Apache | CSS: CSS Border | CSS Syntax | CSS Selector | CSS Comment | CVS: CVS Release | CVS Login | CVS Logout | CVS Annotate | Databases: Rolap Tutorial | OLAP Tutorial | OLTP Tutorial | data warehousing | Expect: HTML: html | Linux: Dot (.) conf files | Linux Mount Point | Linux Filesystem | SSH Tutorial | Linux Commands: cal | cat | cfdisk | chroot | MySQL: MySQL Commands | PHP: PHP Basics | PHP Variables | PHP Output (echo/print) | PHP String Concat | PL/SQL: PL/SQL Data Types | PL/SQL Control Structures | PL/SQL File Extensions | PL/SQL DBMS_OUTPUT package | Python: My first Python program | Shell: Starting Bash | Bash Redirection | Bash Pipes | Bash Variables | SQL: SQL Transactions | SQL Constraints | SQL Drop | SQL Union & Union All | SVN: svn architecture | SVN Repository | SVN Import | SVN Checkout | Tech: soap | Web Designing: Web Hosting | HTML/XHTML/CSS code validator | Learn FTP | Search Engine Optimization Tips | www: XML: XML vs HTML | XML Syntax | XML Tags, Elements and Attributes | XML Namespaces |
    Sitemap | Disclaim | Privacy Policy | Contact | ©2007-2009 w3reference.com All Rights Reserved.