The Joys of xargs - page 2
xargs and find
Moving on from find: it can be useful to pipe the contents of a file into xargs as input. So,
xargs -t -n2 diff < diff-fileswould take the arguments listed in the file diff-files in groups of 2 and run diff on them. So if the diff-files file consisted of:
sample1 alternate1 sample2 alternate2then xargs would run:
diff sample1 alternate1 diff sample2 alternate2This can be a quick way of comparing large numbers of files. (Use -p instead of -t to get a pause after each diff as well as an echo of the command.)
You can also use a listings file and xargs to concatenate the contents of those files:
xargs cat < list-of-files > files-contents(generate list-of-files using xargs as well!
find . -maxdepth 1 -name '*.tex' | xargs echo > list-of-fileswould get all your LaTeX source files in the current directory into one list, ready to be stuck together.)
Solid state disks (SSDs) made a splash in consumer technology, and now the technology has its eyes on the enterprise storage market. Download this eBook to see what SSDs can do for your infrastructure and review the pros and cons of this potentially game-changing storage technology.
- 1Linux Top 3: GNOME 3.12 and New Betas for Ubuntu 14.04 and OpenMandriva Lx 2014.0
- 2Linux Top 3: Linus Lashes out, Linux 3.14 Gets PIE and Ubuntu One is Done.
- 3Linux Top 3: Ubuntu 14.04, Debian Gives Squeeze More Life and Red Hat Goes Atomic
- 4Linux Top 3: RHEL 6.5, Debian 7.2 and EOL for Linux 3.0.x
- 5Linux Top 3: CoreOS, Oracle Enterprise Linux 7 and Ubuntu 14.10