This makes for good reading: http://porkmail.org/era/unix/award.html
This makes for good reading: http://porkmail.org/era/unix/award.html
<input.txt tr -d \\n >output.txtYou get a blank screen, but if you do:
cat file-that-doesnt-exist.txt | less
You get a nice error message:
cat: 'file-that-doesnt-exist.txt': No such file or directory
$ < not_existant_file less bash: not_existant_file: No such file or directory
I just tried this on bash 4.3. Cat remains superfluous in this case.
At least with "in appropriate use of cat" (as some call it) you're literally just swapping the stdin file stream with a disk io file stream so there's no functional difference what-so-ever.
I'm not saying I agree with the GP either though as most of the time complaints about "in appropriate use of cat" are just showboating. Using `cat` "inappropriately" is arguably more readable for less seasoned shell script developer and it's certainly a more logical program flow for a human to parse. ie "open file, grep for contents, do something else, etc". But it's still sometimes worth a reminder that many string processing tools can accept file input directly without the need for piping it via stdin (or the files can be redirected directly from the shell via the less than, `<`, token).
amirite?
pgrep often fails me I think mostly for apps the edit their cmdline and it needs to whole word match I think?
ps | grep [g]rep
Though it is still a bit terrible.If you mean adding a 'cat' at the start to provide a clear entry-point for the data, you can actually put the redirect at the beginning:
< example.txt grep cheese | tac > cheesy_lines.txt