Last active
August 22, 2018 14:17
-
-
Save Integralist/cfd543d2fb68eb2f14c3f02d14f64226 to your computer and use it in GitHub Desktop.
[Sed Ignore Lines] #sed #ignore #regex #patterns
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
# imagine you have multiple lines (non-deterministically generated): | |
# | |
# server 127.0.0.1; other stuff | |
# server 127.2.2.2:2222; other stuff | |
# | |
# to replace the second line and not the first, you can use the /.../! syntax | |
# this says "as long as the first pattern doesn't match, go ahead and try the substitution" | |
# | |
# sed -i '/some_pattern_to_ignore/! s/some_pattern_to_match/the_replacement_for_the_match/g' /nginx.conf | |
sed -i '/server 127.0.0.1/! s/server [^:]\+:[^;]\+/server 127.0.0.1:9000/g' /nginx.conf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment