redirection in unix - aka angled brackets

2019-12-20

 | 

~1 min read

 | 

170 words

Today I wanted to learn how to programmatically update a file with shell scripting.

Turns out that there are multiple approaches and it depends on whether or not you’re okay with a destructive action or not.

The short answer: > will push data from what’s to the left of the bracket to the right. This is potentially destructive. >> will push data in a non-destructive way by appending the data only.

I found Paul Brown’s tutorial on the differences between the angle brackets over at Linux.com really accessible and informative.

For an even more in-depth look, the Advanced Bash-Scripting Guide has a great chapter on Redirection is fantastic and contains lots of relevant examples.

Update: A few more examples on ways to use standard redirects (>) courtesy of Warren Hill’s answer on StackExchange:

  • > file redirects stdout to file
  • 1> file redirects stdout to file
  • 2> file redirects stderr to file
  • &> file redirects stdout and stderr to file

Related Posts
  • Copy File Contents From The Command Line
  • Cloc: Code Base Analysis
  • Readline In Node For Processing STDIN & STDOUT
  • Node Version Management... Automatically


  • Hi there and thanks for reading! My name's Stephen. I live in Chicago with my wife, Kate, and dog, Finn. Want more? See about and get in touch!