hi all
The following sed command replaces the OLD string with the NEW string.
My target is to replace the OLD to NEW only if COMMAND word appears as the first word in the line.
How to fix my sed syntax in order to replace OLD with NEW only if COMMAND is the first word in line?
(Note: COMMAND word location could be after some spaces from the line beginning.)
lidia
sed "/^ *#/b; /COMMAND/ s/OLD/NEW/g" file
COMMAND OLD
OLD COMMAND
after sed exe:
COMMAND NEW
NEW COMMAND