Created
August 16, 2018 03:30
-
-
Save jhsea3do/7b4db1924fbd26192795593751ba4c7d to your computer and use it in GitHub Desktop.
sed replace or append example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://superuser.com/questions/590630/sed-how-to-replace-line-if-found-or-append-to-end-of-file-if-not-found | |
sed '/^FOOBAR=/{h;s/=.*/=newvalue/};${x;/^$/{s//FOOBAR=newvalue/;H};x}' infile |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment