Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I remove a line(record) if data is missing from column 1 to 32 1

Status
Not open for further replies.

tpbjr

MIS
Oct 8, 2004
120
US
I am process an input file by using the help from thread #thread271-930638. The problem is sometimes the input file has a blank line at the end. After everything is combined I will have data that looks something like this:

1234567This is a test spca10112004
12345 This is a test spca10112004
spca10112004
123 This is a test spca10112004

Notice the missing data. This is because the first file read in had a blank last line. I need to remove this line before using it as input to the next part of the process.
There could be over 50 files read in and combined together so that means there could be missing data in other places, I just produced this file for example purposes.


Thanks for all your help in advance.

Tom

 
Use this condition in the pattern space:
NF>0{...}

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks for the input but I must be missing something. I tried the following and it produced the same exact file.

awk NF>0 test1.dat > test2.dat

and

awk NF>20 test1.dat > test2.dat


What do you think I am doing wrong?

Thank you for all your help

Tom
 
Where is your awk program in your post ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
I currently have this test.ksh

#!/usr/bin/ksh
awk -v d=$(date "+%m/%d/%Y") -f vendor.fmt spcavndor* > test1.dat

if [ $? -ne 0 ]
then
echo JOB FAILED
exit 1
fi




format file is:

BEGIN{ FS="|" }

{ printf "%-7.7s%-32.32sSPCA%s\n", $1, $2, d }


The end result of this process can be something like this, and lets say this result came from two separate files.

123456 testing spca10112004
spca10112004
1234567testing again spca10112004

I want to get the middle line out becaue it came from a blank line in the first file.


Does this help you help me better?

Thank you for all your help

Tom
 
Replace this:
{ printf "%-7.7s%-32.32sSPCA%s\n", $1, $2, d }
By this:
NF>1{ printf "%-7.7s%-32.32sSPCA%s\n", $1, $2, d }

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Your a frig'n genious:)

Thank you so much!

Do you have a UNIX book that you could recommend.
I have always been able to teach myself programming, such as Dbase, Clipper, VB, MS Access, PL/SQL but this unix stuff just blows my mind and I have not had any success with books here in the shop.

Now I only pray they dont' change the input file requirements:)

Thanks again.

Thank you for all your help

Tom
 
I personally use the man command, like this:
man awk

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top