December 20, 2019
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.
Thanks for reading! My name's Stephen Weiss. I live in Chicago with my wife, Kate, and dog, Finn.
Click here to see the archives of my weeks in review and sign up yourself!