How to find line startwith and replace in linux.
file:/usr/test.pl
startswith: "abc.xyz" => "0"
replace: "abc.xyz" => "1"
Note before: "abc.xyz" three spaces
I achieved using python script
newlines = []
with open ('/usr/test.pl', 'r') as f:
for line in f:
if "\"abc.xyz\" => \"0\"" in line
newlines.append(" \"abc.xyz\" => \"1\",\n")
else:
newlines.append(line)
with open ('/usr/test.pl', 'w') as f:
for line in newlines:
f.write(line)
Same how to achieve in bashscript or sed command.