bash - unix sed command does not work -
i'm trying edit file called bookdb.txt contains
boy:man:67.00:15:28 harry potter - order of phoenix:j.k.rowling:70.00:40:20 harry potter - half blood prince:j.k.rowling:40.00:50:20
this command
sed -i "s/""$title""/""$newtitle""/g" ./bookdb.txt
it works. want make sure edits exact string of $title, because if lets contains "a", letter in file changed. how use <\ \>
in case ?
a simple option try, since title begins @ beginning of line , delimited colon, this:
sed -i "s/^""$title:/""$newtitle"":/g" bookdb.txt
note ^
anchors match beginning of line, , :
in both match , replacement section.
Comments
Post a Comment