Last active
August 29, 2015 14:16
-
-
Save cybersamx/bc1f8bfc3a0d95c5c298 to your computer and use it in GitHub Desktop.
Ways for sed to match and replace lines
This file contains hidden or 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
# Remove all occurences of string_to_match | |
sed -i '/string_to_match/d' file | |
# Match and add new string line | |
sed -i '/string_to_match/a new_string' file | |
# Match string and replace the entire line with string line | |
sed -i '/string_to_match/c\new_string' file | |
# Match the string and replace with sring | |
sed -i '/string_to_match/new_string/g' file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment