Live data from Hacker News

PSA about abuse of cat(1) command. Don't abuse cats

abuseofcats.com

11–20 of 62 posts

Re: PSA about abuse of cat(1) command. Don't abuse cats

#11
post #3

> Since 1995, occasional awards for UUOC have been given out, usually by Perl luminary Randal L. Schwartz http://catb.org/jargon/html/U/UUOC.html Admittedly its taken me a long time to remember that the file is the last argument to grep, when so many other commands its the first. I'd guess common abuse is due to being easier to type cat x | than to dig up the man page

The redirection operator is consistent and requires less typing though.

I guess the file is usually the last argument because it's the one that can be omitted.

Re: PSA about abuse of cat(1) command. Don't abuse cats

#12
post #3

> Since 1995, occasional awards for UUOC have been given out, usually by Perl luminary Randal L. Schwartz http://catb.org/jargon/html/U/UUOC.html Admittedly its taken me a long time to remember that the file is the last argument to grep, when so many other commands its the first. I'd guess common abuse is due to being easier to type cat x | than to dig up the man page

It's that way so that you can grep multiple files with a single pattern. It would be odd for the pattern to come after the file arguments. It also allows the files to be optional so that it can grep stdin.

Re: PSA about abuse of cat(1) command. Don't abuse cats

#16
Don't do this:

  cat file | wc -l            => wc -l  head -n 5 file
  cat file | awk '{print $1}' => awk '{print $1}' file
  cat file | sort             => sort file
Do this instead:

  cat file | wc -l            =>    
The front-cat abuse is all about the order. The effective solution needs to keep the relative order of arguments.

Re: PSA about abuse of cat(1) command. Don't abuse cats

#19

Don't do this: cat file | wc -l => wc -l head -n 5 file cat file | awk '{print $1}' => awk '{print $1}' file cat file | sort => sort file Do this instead: cat file | wc -l => The front-cat abuse is all about the order. The effective solution needs to keep the relative order of arguments.

Or just use cat and spend your brainpower on interesting, useful, and/or worthwhile topics. It boggles my mind that anyone cares about this.
Post reply on HN