perl like sed + match word and replace
- by yael
Is it possible to change the perl syntax (described down) to replace "a" string in the line that match "param1" as the following example:
more test
param1=a
a
param2=b
b
aa
bb
a
b
aa
bb
[root@localhost tmp]# perl -pe "s/\b$a\b/$b/g unless /^#/" test
param1=asdfghj
asdfghj (this line shuld not be chaged)
param2=b
b
aa
bb
a
b
aa
bb
[root@localhost tmp]#
The right output
param1=asdfghj
a
param2=b
b
aa
bb
a
b
aa
bb
[root@localhost tmp]#