Reputation: 1481
I'm currently using 's/string/new_string/g'
to go through some CSV files, however I'm running into difficulty in the following scenario:
I want to replace instances of '192.168.0.11'
, however it's also catching instances of '192.168.0.111'
.
How can I ensure sed only grabs '192.168.0.11'
and not '192.168.0.111'
? I'll obviously have to repeat this for many variables, so something easily scalable would be appreciated.
Thanks!
Upvotes: 12
Views: 26880
Reputation: 12806
I'm not sure what the regex you are using is, but if you want an exact match of '192.168.0.11' you can use:
s/\<192\.168\.0\.11\>//g
The \<\>
force an exact match.
Upvotes: 24