Link to home
Start Free TrialLog in
Avatar of shlomi
shlomi

asked on

Filtering text

I have a file that looks like:
text text

text text

every second line is a \n char, How do i filter the \n chars (can be second line or just \n)
Avatar of crawlspace
crawlspace

Use the chomp method in Perl.

This perl script reads in a file and spits it back out without any "\n"'s.

#!/usr/bin/perl

open(INFD,$infile) or die "$!\n";
while(<INFD>) {
     chomp;
     chomp;
     print;
}


Avatar of ozo
grep -v '^$'
Avatar of shlomi

ASKER

I don't have perl installed and i don't want to install
Avatar of shlomi

ASKER

OZO your comment is doing the work how do i reward you with the points ?
ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial