I need to replace a word after multiple spaces :
actually the file contains this string :
local all all
Am I missing some part of this problem? I made a file with the first line above as contents, then ran the simplest possible sed command on it ... and came out with the 2nd line.
~ >cat test.txt
local all all peer
~ >sed 's/peer/md5/g' test.txt
local all all md5
works fine with multiple lines as well ...
~ >cat test.txt
local all all peer
local all all peer
local all all peer
local all all peer
local all all peer
local all all peer
~ >sed 's/peer/md5/g' test.txt
local all all md5
local all all md5
local all all md5
local all all md5
local all all md5
local all all md5
The only time this will not work is if the word "peer" shows up somewhere else on a line where you do not want it replaced with md5 ...
This one replaces only the first occurance of the search term:
~ >cat test.txt
local all all peer
local all all peer
local all all peer
local all all peer
local all all peer
local all all peer
~ >sed '0,/peer/s//md5/' test.txt
local all all md5
local all all peer
local all all peer
local all all peer
local all all peer
local all all peer