O'Reilly logo

Practical UNIX by Steve Moritsugu - DTR Business Systems

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

Using Perl to Replace or Delete Strings

Perl is a complete programming language that runs under both UNIX and Windows. Although it usually does not come packaged with any commercial UNIX distribution, it is readily available via the Internet for most UNIX systems. If Perl is available on your system, you can also use it as a simple command-line utility that provides replacement capabilities not available in sed.

For simple replacement, perl is just like sed if you use the –pe option to perl. The following two commands are equivalent:

     sed 's/Mr. Smith/Ms. Wilson/g' report7
perl -pe 's/Mr. Smith/Ms. Wilson/g' report7

Earlier, this chapter discussed the g flag for sed. It means the same thing to perl: process all patterns on the line, not just ...

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