Created
October 26, 2013 11:37
-
-
Save izimbra/7168469 to your computer and use it in GitHub Desktop.
Replaces first occurrence of a string in a file using sed.
This was tried and worked in OS X 10.9.
#osx #shell #sed
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
sed '1,/string/ s/string/replacement/' file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
to change in a text file (inplace),
sed -i '.txt' '1,/string/ s/string/replacement/g' ~/.zshrc
works fine for me