~ $ ( cd tmp/a/b/c/ || mkdir -p tmp/a/b/c && \
> VAR=$PWD; cd ~; tar xvf -C $VAR archive.tar ) \
> | mailx admin -S "Archive contents"
|
~ $ { cp ${VAR}a . && chown -R guest.guest a && \
> tar cvf newarchive.tar a; } | mailx admin -S "New archive"
|
~ $ find some-file-criteria some-file-path | \
> xargs some-great-command-that-needs-filename-arguments
|
~ $ xargs
a
b
c
Control-D
a b c
~ $
|
~/tmp $ ls -1 | xargs
December_Report.pdf README a archive.tar mkdirhier.sh
~/tmp $ ls -1 | xargs file
December_Report.pdf: PDF document, version 1.3
README: ASCII text
a: directory
archive.tar: POSIX tar archive
mkdirhier.sh: Bourne shell script text executable
~/tmp $
|
~/tmp $ ls -l | xargs
-rw-r--r-- 7 joe joe 12043 Jan 27 20:36 December_Report.pdf -rw-r--r-- 1 \
root root 238 Dec 03 08:19 README drwxr-xr-x 38 joe joe 354082 Nov 02 \
16: 07 a -rw-r--r-- 3 joe joe 5096 Dec 14 14:26 archive.tar -rwxr-xr-x 1 \
joe joe 3239 Sep 30 12:40 mkdirhier.sh
~/tmp $
|
~ $ time grep and tmp/a/longfile.txt | wc -l
2811
real 0m 0.097s
user 0m 0.006s
sys 0m 0.032s
~ $ time grep -c and tmp/a/longfile.txt
2811
real 0m 0.013s
user 0m 0.006s
sys 0m 0.005s
~ $
|
~ $ grep -o and tmp/a/longfile.txt | wc -l
3402
~ $
|
~/tmp $ ls -l /tmp/a/b/c | grep Dec
-rw-r--r-- 7 joe joe 12043 Jan 27 20:36 December_Report.pdf
-rw-r--r-- 1 root root 238 Dec 03 08:19 README
-rw-r--r-- 3 joe joe 5096 Dec 14 14:26 archive.tar
~/tmp $
|
~/tmp $ ls -l | awk '$6 == "Dec"'
-rw-r--r-- 3 joe joe 5096 Dec 14 14:26 archive.tar
-rw-r--r-- 1 root root 238 Dec 03 08:19 README
~/tmp $
|
~ $ time cat tmp/a/longfile.txt | grep and
2811
real 0m 0.015s
user 0m 0.003s
sys 0m 0.013s
~ $ time grep and tmp/a/longfile.txt
2811
real 0m 0.010s
user 0m 0.006s
sys 0m 0.004s
~ $
|