Watael wrote:
grrr, there is no good reason for using cat in bash scripts!
Code:
echo "$(<output.log)"
he he he, well.... While I would agree that
cat is used way more than necessary.... I'd disagree that there is no good reason to use cat in a bash script...
Here are some.
An extremely simple method to write to a new file.
cat > somefile
<enter information here>
<when done CTRL-D>
Create an actual line numbered copy of your file
cat -n somefile num_somefile
View special characters that might be in a file
cat -v somefile
<this shows CTRL chars etc>
The normal use
cat file1 file2 file3 > newfile
print file1 and file2 to standard output
cat file1 file2
And for clarity.... I ALWAYS use
cat filename | sed/awk/grep .....especially if I have multiple pipes... it's just easier to read. I understand it isn't technically correct... but it is much clearer to read, not to mention less to type.
Purists tend to stay away from using cat, they also tend to stay away from sed/awk and use bash parameter substitution too. But neither make it easier to understand what the program is actually doing. As a systems administrator, I would prefer to see/read a script that is documented and easy to understand quickly...but that's just me
However, if I was writing something that was going to be released on sourceforge or something like that, I'd definitely tidy up my code
