Re: Newbie question: delete newline character with sed
hzmo...@hotmail.com wrote:
> > sed '/^[ \t]*$/d' does not work
> Sorry guys, I just found out that
> 1. I probably missed the space inside the square brackets, and
> 2. I did not know I need to type a Ctrl-v before typing a real tab in
> order for the shell to recognize the tab character
> Now it works.
> Further, sed 's/[ ]*$//'
> where there is a space and a tab character between the [ and the ]
> removes trailing spaces from each line.
> How can I combine these two sed commands so that both empty lines and
> trailing spaces (and tabs) are removed? Thanks.
Just connect them with a simicolon:
sed '/^[ ]*$/d; s/[ ]*$//;'
Xicheng :-)
|