hzmonte@hotmail.com wrote:
> From: qazwart
> Date: Thurs, Apr 7 2005 9:20 am
> Email: "qazwart" <qazw...@gmail.com>
> Groups: comp.unix.shell
>
> Remember that sed has more commands in it than just "s" for
> substitution:
>
> sed '/^$/d'
>
> Any line that matches the pattern "/^$/" (blank lines) will be deleted
> from the input. If you want to delete lines that may contain spaces and
> tabs, but nothing else, you need to use this:
>
> sed '/^[ \t]*$/d
>
> The "\t" doesn't work with all versions of sed, so you might need to
> use a real tab character instead.
>
> ============================
> sed '/^$/d' works, i.e. removes empty lines, but sed '/^[ \t]*$/d' does
> not - the lines that have tabs and spaces are still there. I tried
> sed '/^[]*$/d' (a real tab between the square brackets)
> and
> sed '/^*$/d' (a real tab between ^ and *)
> and neither works. (The real tab does not show up in the command
> line.)
you may try "POSIX character class" to see if it s.
sed '/^[[:space:]]*$/d'
which removes lines containing only whitespaces(TAB, NEWLINE,
SPACE,.....)
Xicheng