Hello, is it possible to replace exact words with awk and gsub? The command: Code: /usr/bin/awk '{gsub(/master/,"slave");print}' /tmp/test > /tmp/test1.temp does replace ALL master to slave, but it also replaces blahblahmaster to blahblahslave, which i do not want... Thanks!
You know how regular expressions work, right? You know the meaning of "the empty string at either the beginning or the end of a word", right?
thanks for reminding Code: /usr/bin/awk '{gsub(/ master/," slave");print}' /tmp/test > /tmp/test1.temp does do the job
You are welcome. As an aside, " " is not the empty string, and many implementations of regular expressions (including that of GNU awk) have a particular syntax for the empty string at the beginning and/or end of a word, i.e. the transition between word characters and non-word characters.