/
๐Ÿ‘‹

Updating files with Sed

SedBash
Table of contents
  • Installing on a Mac
  • Updating a file that exists

Installing on a Mac

It turns out that sed doesn't work as expect on Macs, instead you should install gsed from homebrew:

bash
homebrew install gsed

You can then use gsed in place of sed.

Updating a file that exists

To update a file that exists you need to:

bash
gsed -i "pattern to update" filename.txt

For example:

bash
gsed -i "8iFeatureEnabled: true" featureFlags.txt

would add FeatureEnabled: true onto the 8th line of featureFlags.txt

Want to make your own site like this?
Try gatsby-theme-code-notes by Zander Martineau.
A dumping ground of small useful code notes