using sed to replace whole word containing '='?
EDIT
i have something like this in a file: imagecolor=0 arrayimagecolorcopy=0 arrayimagecolorcopy3d=0when i use sed -i -e 's/imagecolor=0/imagecolor=1/'
it will chan开发者_如何学Goge 1 and 2 line. But i only want it to replace first line.
Thank you.
It seems to work for me:
$ echo 'imagecolor=0
> imagecolorcopy=0
> imagecolorcopy3d=0' > input.txt
$ sed -i -e 's/imagecolor=0/imagecolor=1/' input.txt
$ cat input.txt
imagecolor=1
imagecolorcopy=0
imagecolorcopy3d=0
If you only want to make the substitution when the entire line matches, try anchoring your regular expression:
$ sed -i -e 's/^imagecolor=0$/imagecolor=1/' input.txt
精彩评论