1828634 Members
1812 Online
109983 Solutions
New Discussion

parsing data

 
SOLVED
Go to solution
Nick D'Angelo
Super Advisor

parsing data

I have the output from a cronjob to report on the size of tables in a db.

But if you look below, there are a number of tables that have 0 bytes (empty) and I want to remove them so that I only need to look at the tables with actual data in them.

Suggestions are always appreciated.

abs_mstr 0 0 0 0 0 0.0 0.0
accd_det 0 0 0 0 0 0 0.0 0.0
acd_det 48105 2531643 37 73 52 48105 1.0 3.8
acm_mstr 0 0 0 0 0 0 0.0 0.0
act_mstr 0 0 0 0 0 0 0.0 0.0
acx_mstr 0 0 0 0 0 0 0.0 0.0
ac_mstr 472 31355 47 73 66 472 1.0 5.7


Always learning
6 REPLIES 6
James R. Ferguson
Acclaimed Contributor
Solution

Re: parsing data

Hi Nick:

From the pattern of your data, this would do it:

# awk '$2>0 {print $0}' /tmp/filein > /tmp/fileout

Regards!

...JRF...
Robin Wakefield
Honored Contributor

Re: parsing data

Hi Nick,

How about:

grep [1-9] filename

Rgds, Robin
A. Clay Stephenson
Acclaimed Contributor

Re: parsing data

Hi Nick:

Something like this:

cat infile | awk '{ if ((($2 + 0) > 0) || (($3 + 0) > 0)) print $0 }'

or pipe the output of your command to the awk. Note: The $2 + 0 forces the comparison to be numeric.

Clay
If it ain't broke, I can fix that.
Sridhar Bhaskarla
Honored Contributor

Re: parsing data

Nick,

awk will help you to simplify this. You can print out only those lines that satisfy the condition on a particular (or a group of) column. If you want the second column (it is $2 in awk's parsing) to be determined as non-zero, you would give

awk '$2>0 {print $0}' your_file

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
Lou Zirko_1
Frequent Advisor

Re: parsing data

Another method would be the grep below:

grep -v "0 0 0 0 0 0.0 0.0" filename

This will print all lines that do not have a "0 0 0 0 0 0.0 0.0" pattern in them.

Lou Zirko

Nick D'Angelo
Super Advisor

Re: parsing data

Thanks for all the solutions.

issue closed.
Always learning