I get that tac exists and is useful for concatenating and printing files in reverse.
Neilk was just humorously pointing out that since cat stands for concatenate, its reverse should be truncate, and since cat is often abused to print a single file to a terminal this fictional trunc should "unprint" it.
Arguably you could view 'comm -3' as the reverse of cat.
# output is all the lines of file1 and file2
cat file1 file2
# output is the lines in file1 not in file 2, and vice verse
comm -3 file1 file2
With 'cat > file' you can actually type in the file's contents (then press ^d to finish). 'touch file' merely creates an empty file. (Not that I think 'cat > file' is much faster than 'vi file')
I tend to prefer the cat version as the flow of the command follows the left-to-right direction in which I generally read, and it makes things easier for less experienced users to read and understand for the same reason.
It does make things less efficient of course, as there is at least one extra memory-copy of everything and extra process context switching, but in most cases your drives or network are the bottleneck not CPU speed or memory bandwidth. Also, when working on the command line you can drop in useful tools like pv in place of cat.
The "convert file into arguments" trick is useful, but a "while read/do" loop would be better:
cat file | while read INPUT
do
command "$INPUT"
done
... which will read the entire line from 'file' into the shell variable "$INPUT", inclusive of whitespace. If you need to do further parsing, of course, you can do that within the loop.
Trap: since you're creating a subshell (at least in bash/Bourne), variables defined within the loop are NOT defined after it exits.
You may also create new empty files by saying `touch filename`. This saves three keystrokes (which includes an annoying `>` symbol, requiring the shift key) as compared to the aforementioned `cat` method!
what do you mean? "cat > file" allows you to create simple text file not just empty files. As long as you don't need advanced editing, it is the quickest way to do it (well I think).
The nl command (part of coreutils) is specifically written for numbering lines. It can do simple line numbering, along with various other styles and formats.
When I was young, I used cat and grep like that until an old Unix sys-admin remarked "What a gratuitous use of cat!". At the time, I did not understand what he meant, but now I do. So whenever I see cat and grep used like this, I think back to that lesson I learned.