Sed replacing words with abbreviations

I really hate to do this, but I am completely stumped. I have to create a sed script that will change the abbreviations in a file to the full word. I really just have no idea where to start. All I want is a starting point as well no actual complete answer. Thank you for your time in advance.

~mauler123

Nevermind I figured it out I did

cat addresses.txt | \sed -e 's/Ave./Avenue/' | \sed -e 's/St./Street/' | \sed -e 's/E./East/' | \sed -e 's/Ter./Terrace/' > addresses4.txt

and that worked for what I needed to do. Although after looking at my solution I don't think I posted in the right section, sorry!

Hi there,
I think this was the correct forum. At least it's the one I use.
If your not very familiar with sed, here are some remarks:
1) You can put all the replacements in one sed

cat addresses.txt | sed -e 's/Ave./Avenue/; s/St./Street/; s/E./East/; s/Ter./Terrace/' > addresses4.txt

2) Without the g option, only the first occurence of the string in each line will be replaced. I know it's not very likely to have "Ave." appear two times in an address, but you'd better be sure

cat addresses.txt | sed -e 's/Ave./Avenue/g; s/St./Street/g; s/E./East/g; s/Ter./Terrace/g' > addresses4.txt

3) You don't need to cat the file, just give it as an argument

sed -e 's/Ave./Avenue/g; s/St./Street/g; s/E./East/g; s/Ter./Terrace/g' addresses.txt > addresses4.txt

4) And if you want to replace the file itself, use the i switch

sed -i 's/Ave./Avenue/g; s/St./Street/g; s/E./East/g; s/Ter./Terrace/g' addresses.txt

5) Beware that a period (.) is a special character that represent any other one. Which means that Aven, Avel, Aved all match Ave. and will be replaced by Avenue. Escape the period to match an actual period.

sed -i 's/Ave\./Avenue/g; s/St\./Street/g; s/E\./East/g; s/Ter\./Terrace/g' addresses.txt

I hope I helped
Santiago

Thanks for the info. I used a cat and just read the file first first so I knew exactly what I needed to replace beforehand, which is why what I used worked.

All of the other information was a lot of help thanks!

Take a read: UUOC