0

I want to remove blank lines (empty or with spaces and tabs) from a file from within a perl script.
here's what i tried.

`sed '/^ *\$/d' $file1`;

Does not seem to work for some reason.
Any Help please?

2
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by voidyman
0

Take out the space (unless you are looking for lines with just one space)

^$

So, given a file called test.txt, JUST the sed part would be:

sed '/^$/d' test.txt

Edited by thines01: added code

0

thanks for your replies. $^ matches a blank line(but not a line with spaces). I eventually ended up calling the perl inline from my script. :)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.