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

27.3. del.lines

This script came about because the developers kept asking me ‘what was that sed command to delete blank lines again?’ I decided I would knock up a little script for them to use, which would save them the trouble of ringing me up for the command.

The script is really a wrapper for the sed delete command, but it keeps the developers happy, and it gets used a lot.

Shell scripts do not have to be long. If a task can be automated and it saves you time, script it.

del.lines can take a single file or multiple files. Each file is checked for its presence before sed does the work of deleting all blank lines. The output of sed is directed to a temporary file using $$, and the file is then moved back to replace the original file.

Shift ...

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