O'Reilly logo

Linux and Unix Shell Programming by David Tansley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

10.10. Using sed on the system

We have now gone over the basics of sed, but what you really use sed for in your scripts or on the shell line is changing or deleting text from strings or files. That’s what we will look at next, using what we have learnt in the previous section.

10.10.1. Dealing with control characters

One task for which you’ll use sed a lot will be stripping off control characters from files that have been downloaded from another system.

Here’s a part of a file (dos.txt) that has been transferred. We’ve got to get rid of all the suspect characters so the accounts department can use the file.

							$ pg dos.txt 
12332##DISO##45.12^M 
00332##LPSO##23.11^M 
01299##USPD##34.46^M 
...
						

Here’s what has got to be done:

1.
Replace all the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required