Issue
I have a document with the next data:
SOMETHING_NAME=something
NAME=somethingmore
And when I run the next command:
sed -i "/NAME=/c NAME=newsomething" ./file
The command edit all matching with NAME, so I need to match only the second line.
file after:
NAME=newsomething
NAME=newsomething
The output I need:
SOMETHING_NAME=something
NAME=newsomething
Solution
If you add a caret (^) to the regex that will match from the start of the line, as follow.
sed -i "/^NAME=/c NAME=newsomething" ./file
Answered By - toppk Answer Checked By - Katrina (WPSolving Volunteer)