|
how to find and replace only the 2nd occurrence of similar string in a file
hi how do u replace only the 2nd occurence of similar string in a file?
eg in test.txt
num_oper = 1
oper = mem
i wrote a script to replace only oper the 2nd object in test.txt but it seem that both num_oper and oper got replaced. my script is as follow:
sed -n s/oper=[a-z]*/oper=rim/p test.txt
output:
num_oper = rim1
oper = rim
|