logoalt Hacker News

lifthrasiirtoday at 2:20 AM1 replyview on HN

Don't do this:

  cat file | wc -l            => wc -l < file
  cat file | head -n 5        => 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            => <file wc -l
  cat file | head -n 5        => <file head -n 5
  cat file | awk '{print $1}' => <file awk '{print $1}'
  cat file | sort             => <file sort
The front-cat abuse is all about the order. The effective solution needs to keep the relative order of arguments.

Replies

stousettoday at 2:25 AM

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

show 2 replies