Tip 1
"cat" the Contents of Files Listed in a File, in That Order.
SETUP (Assume you have the following)
$ cat file_of_files
file1
file2
$ cat file1
This is the data in file1
$ cat file 2
This is the data in file2
So there are 3 files here "file_of_files" which contains the
name of
other files. In this case "file1" and "file2". And the contents of
"file1" and "file2" is shown above.
$ cat file_of_files|xargs cat
This is the data in file1
This is the data in file2
Tip 2
Columns and Rows -- getting anything you want.
Assume you have the following file.
$ cat data
1 2 3
4 5
6 7 8 9 10
11 12
13 14
How to you get everything in 2 columns?
$ cat data|tr ' ' '\n'|xargs -l2
1 2
3 4
5 6
7 8
9 10
11 12
13 14
Three columns?
$ cat data|tr ' ' '\n'|xargs -l3
1 2 3
4 5 6
7 8 9
10 11 12
13 14
What's the row sum of the "three columns?"
$ cat data|tr ' ' '\n'|xargs -l3|tr ' ' '+'|bc
6
15
24
33
27
or
$ tr ' ' '\n' < data |xargs -l3|tr ' ' '+'|bc
NOTE "Steven Heiner's rule":
cat one_file | program
can always be rewritten as
program < one_file
Note: thanks to Steven Heiner (http://www.shelldorado.com/) the
above can be
shortened as follows:
$ tr ' ' '\n' < data|xargs -l3|tr ' ' '+'|bc
Need to "tr" from the stdin?
$ tr "xy" "yx"| ... | ...
But there is a the "Stephane CHAZELAS" condition here
"Note that tr, sed, and awk mail fail on files containing '\0'
sed and awk have unspecified behaviors if the input
doesn't end in a '\n' (or to sum up, cat works for
binary and text files, text utilities such as sed or awk
work only for text files).