Skip to content
koalaman edited this page Apr 19, 2014 · 7 revisions

Consider using { cmd1; cmd2; } >> file instead of individual redirects.

Problematic code:

echo foo >> file
date >> file
cat stuff  >> file

Correct code:

{ 
  echo foo
  date
  cat stuff
} >> file

Rationale:

Rather than adding >> something after every single line, you can simply group the relevant commands and redirect the group.

Contraindications

This is mainly a stylistic issue, and can freely be ignored.

Clone this wiki locally