Delimiter file

I have .txt file with | (pipe) delimiter in AIX 5.2

If the very first column (before the 1st delimiter) is blank, I need to remove the entire row.
The pattern is xxx|hh:mm:ss tt| to begin with.

G16|07:15:00 AM|SURGERY|IPSIX|1520867|56||01:15:00 AM|31613-TRACHEOSTOMA REVISION; SIMPLE, WITHOUT FLAP ROTATION|bla………. ROTATION||||||||||31613.000000||||||||||||||||||||||||16526467||
||

G14|07:15:00 AM|SURGERY|PEDTWO|1520884|17Y||04:00:00 AM|54550-EXPLORATION FOR UN
DESCENDED TESTIS (INGUINAL OR SCROTAL AREA)|bla…………54550.000000||||||||||||||||||||||||165
17542|17167991|||

T03|07:30:00 AM|QUANTIM|CHUCK|1520587|46||02:00:00 AM|31613-TRACHEOSTOMA REVISION; SIMPLE, WITHOUT FLAP ROTATION| bla…..


T04|07:30:00 AM|QUANTIM|RITA|1520678|6 months||11:00:00 AM|43280-LAPAROSCOPY, SURGICAL, ESOPHAGOGASTRIC FUNDOPLASTY (EG, NISSEN, TOUPET PROCEDURES)|bla……

T05|07:30:00 AM|QUANTIM|WILMA|1520673|39||00:30:00 AM|10060-INCISION AND DRAINAGE OF ABSCESS; SIMPLE OR SINGLE|bla……SINGLE||||||||||10060.000000||||||||||||||||||||||||15544367||||

T02|07:30:00 AM|SURGERY|DOEONE|1520900|106|TRU TRU Pre Arv Doe TRU Pre Arv Doe|05:00:00 AM|61537-CRANIOTOMY W/ELEVATION BONE FLAP; LOBECTOMY TEMPORAL LOBE W/O EMD|||||||ICU Bed||05/08/2006|NEUROSURGER ….

It the row is completely blank, I need to remove the row as well.

After removing rows, I need to save the file cleaned into a new .txt file.

How to do?
JohnLucaniaAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

star_trekCommented:

open(FILE1,"<in.txt");
open(FILE2,">out.txt");
while(<FILE1>) {
     chomp;
     if($_ =~ /^[\w|\d]{3}|\d{2}:\d{2}:\d{2} \w{2}/) {
           print FILE2 $_."\n";
     }
}
close(FILE1);
close(FILE2);
JohnLucaniaAuthor Commented:
delimeter.pl: 0403-057 Syntax error at line 1 : `(' is not expected.

What am I missing here??

root:stmil1:/home/cdi> cat delimeter.pl
open(FILE1,"<in.txt");
open(FILE2,">out.txt");
while(<FILE1>) {
     chomp;
     if($_ =~ /^[\w|\d]{3}|\d{2}:\d{2}:\d{2} \w{2}/) {
           print FILE2 $_."\n";
     }
}
close(FILE1);
close(FILE2);
JohnLucaniaAuthor Commented:
oopps..!  
forgot to put:  
#!/usr/bin/perl -w
OWASP: Threats Fundamentals

Learn the top ten threats that are present in modern web-application development and how to protect your business from them.

star_trekCommented:
you should do
perl delimiter.pl
not cat delimiter.pl
 also in the first line add
#!/usr/bin/perl

so the code is (i am assuming in.txt is the input file)

#!/usr/bin/perl
open(FILE1,"<in.txt");
open(FILE2,">out.txt");
while(<FILE1>) {
     chomp;
     if($_ =~ /^[\w|\d]{3}|\d{2}:\d{2}:\d{2} \w{2}/) {
           print FILE2 $_."\n";
     }
}
close(FILE1);
close(FILE2);

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ozoCommented:
perl -pe "s/^(\|.*)?\n//" <file.txt > new.txt
ahoffmannCommented:
# not as elegant as perl, but ...
awk -F'|' '(NF<1){next}($1==""){next}{print}' file.txt

BTW, ozo you're using double quotes which might cause some unexpected behaviour in some shells
JohnLucaniaAuthor Commented:
great!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Perl

From novice to tech pro — start learning today.