UNIX Scripting

You are incorrect in several ways here.

  1. cat does not do anything here. Your scripts would do the same thing without it.
  2. cat is useless here. Your scripts would be shorter and simpler without it.
  3. cat is counterproductive here. Your scripts would be faster without it. If you ever put code like this inside a loop, UUOC will suddenly become important.
  4. You are limiting your options. Using cat means you can only read from stdin. This rules out a lot of fairly standard and useful awk constructs, etc.

That UUOC looks clearer to you means -- to be blunt -- that you should learn what shell scripts are supposed to look like, instead of relying on bad old habits.

If you really really want to, you can put redirection at the front too in most cases, to get the same 'benefit' without UUOC. <inputfile awk ...

3 Likes