LDP/LDP/guide/docbook/abs-guide/ex3.sh

35 lines
788 B
Bash
Raw Normal View History

2001-07-10 14:25:50 +00:00
#!/bin/bash
2008-07-20 23:16:47 +00:00
# This simple script removes blank lines from a file.
2001-07-10 14:25:50 +00:00
# No argument checking.
2002-09-30 15:56:52 +00:00
#
# You might wish to add something like:
2005-02-09 20:53:43 +00:00
#
2008-07-20 23:16:47 +00:00
# E_NOARGS=85
2002-09-30 15:56:52 +00:00
# if [ -z "$1" ]
# then
# echo "Usage: `basename $0` target-file"
2005-02-09 20:53:43 +00:00
# exit $E_NOARGS
2002-09-30 15:56:52 +00:00
# fi
2001-07-10 14:25:50 +00:00
2008-07-20 23:16:47 +00:00
sed -e /^$/d "$1"
2001-07-10 14:25:50 +00:00
# Same as
# sed -e '/^$/d' filename
2008-11-23 22:43:47 +00:00
# invoked from the command-line.
2001-07-10 14:25:50 +00:00
2002-04-01 16:04:17 +00:00
# The '-e' means an "editing" command follows (optional here).
2008-07-20 23:16:47 +00:00
# '^' indicates the beginning of line, '$' the end.
# This matches lines with nothing between the beginning and the end --
2002-04-01 16:04:17 +00:00
#+ blank lines.
# The 'd' is the delete command.
2001-09-04 13:27:31 +00:00
2002-04-01 16:04:17 +00:00
# Quoting the command-line arg permits
#+ whitespace and special characters in the filename.
2001-07-10 14:25:50 +00:00
2005-02-09 20:53:43 +00:00
# Note that this script doesn't actually change the target file.
# If you need to do that, redirect its output.
2008-07-20 23:16:47 +00:00
exit