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

Popular posts from this blog

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

python - How do I create a list index that loops through integers in another list -

c# - “System.Security.Cryptography.CryptographicException: Keyset does not exist” when reading private key from remote machine -