If I have this command string:
sed '2,6 s/Mary/Sue/g' dear.john
It replaces Mary with Sue in lines 2 thru 6 in the file called dear.john
But in line 6 you have the word Maryland which it replaces with Sueland. Is there anything that I can put in the command string that will change all the Mary's to Sue's but not change not change Maryland to Sueland?
Also is there a way to shorten this command and make it show only the output and not the whole file? I think I'm just putting the flag -n in the wrong place.Am I on the right track?
sed -e '4,8d' -e 's/Mary/mary/g' -e 's/Bill/bill/g' dear.john
Thanks
JJ