Hello,
I am trying to get a grip on sed and regular expressions. I found this site which looked nice but it appears to have mistakes in its examples.
For eg. on this page
http://docstore.mik.ua/orelly/unix/sedawk/ch02_03.htm
There is a file called 'list' and all commands are tested on this file. The file contents are:-
John Daggett, 341 King Road, Plymouth MA Alice Ford, 22 East Broadway, Richmond VA Orville Thomas, 11345 Oak Bridge Road, Tulsa OK Terry Kalkas, 402 Lans Road, Beaver Falls PA Eric Adams, 20 Post Road, Sudbury MA Hubert Sims, 328A Brook Road, Roanoke VA Amy Wilde, 334 Bayshore Pkwy, Mountain View CA Sal Carpenter, 73 6th Street, Boston MA
They have created a script file called sedscr. I have put the text as asked by them which is pasted below
s/ MA/, Massachusetts/ s/ PA/, Pennsylvania/ s/ CA/, California/ s/ VA/, Virginia/ s/ OK/, Oklahoma/
However when I give this as input to the file called 'list', I get an error:- sed: file sedscr line 1: unknown option to `s'
In the earlier examples of substitution sed 's/MA/Massachusetts/" list works only on the first instance of MA and not all which goes against their statements that sed commands are global by default unless the address is specified. The above command will work globally only if the /g option is put in the right had side.
Is there any good website where I can learn sed and regular expressions.