i have a many scripts in a directory & i get many requests to change the code of a particular script.
for example file abc.txt contains
#!/bin/bash
mumbai 102403445
chennai 123980123
delhi 3456268468
kolkata 465376832 #kolkat 462945959
i get a request to change the value ( population of kolkata ) 46852342424
my script should to
#!/bin/bash
mumbai 102403445
chennai 123980123
delhi 3456268468 #kolkata 465376832 # i have to keep old entry as comment
kolkata 4685234242 #kolkata 462945959
so my script should search for KOLKATA and keep old entry as comment and change it to new value. please help me..
>>>NOTES
first couple lines takes input
reads/finds existing line
uses grep to copy everything except
writes the old line begin with #
writes the new line
AND the "^" is an anchor to read from the first column/character in a line