Filter the column and print the result based on condition

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Filter the column and print the result based on condition
# 1  
Old 08-06-2009
Question Filter the column and print the result based on condition

Hi all

This is my output of the some SQL Query

------------------------- ------------------------------------------------------- ---------- --------- --------- ----------
RBS /oracle104/LCSCT1/data/rbs01.dbf 1,000 200 800 20
RBS /oracle108/LCSCT1/data/rbs02.dbf 2,000 1,125 875 56.25
TEMP /oracle101/LCSCT1/data/temp01.dbf 1,500 1,487 13 99.1333333
TEMP /oracle108/LCSCT1/data/temp02.dbf 1,000 987 13 98.7
TOOLS /oracle104/LCSCT1/data/tools01.dbf 50 1 49 2
TOOLS /oracle108/LCSCT1/data/tools03.dbf 500 171 329 34.2
USERS /oracle104/LCSCT1/data/users01.dbf 50 49 1 98
USERS /oracle104/LCSCT1/data/users02.dbf 50 48 2 96
SYSTEM /oracle101/LCSCT1/data/system01.dbf 350 60 290 17.1428571
EASY_LOB01 /oracle107/LCSCT1/data/easy_lob01.dbf 8,000 8,000 0 100
LTK_DATA01 /oracle106/LCSCT1/data/ltk_data01.dbf 4,000 2,404 1,596 60.1
EASY_DATA01 /oracle105/LCSCT1/data/easy_data01.dbf 18,000 3,410 14,590 18.9444444
LTK_INDEX01 /oracle108/LCSCT1/data/ltk_index01.dbf 2,000 1,454 546 72.7
EASY_INDEX01 /oracle106/LCSCT1/data/easy_index01.dbf 5,000 4,960 40 99.2

Now i want to get the all the row's whose "FREE" column output (In this case is the Sixth field) is less than 10.
I want it in seprate file.
To acheive this is did something like,I am not sure its write or wrong.

if [ `cat Datafile_usage.alert | awk -F' ' '{ print $6 }'` le 10 ]
echo "This should print all the rows"

on this i got the following error
unknown operator -------
This is might be because of "------" line , please help me out how to remove those line and how to get the desired output.

This i did to test the things
if [ `cat Datafile_usage.alert | awk -F' ' '{ print $6 }'` le 10 ]
echo "This should print all the rows"
"no Problem"
But i dont want the echo statement , but i want the entire rows

Thanks In Advance
# 2  
Old 08-06-2009
awk '{if ($NF <= 10) {print $0}}' file

# 3  
Old 08-06-2009
awk '(NR > 2) && ($NF < 10)' file1

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Filter duplicate records from csv file with condition on one column

I have csv file with 30, 40 columns Pasting just three column for problem description I want to filter record if column 1 matches CN or DN then, check for values in column 2 if column contain 1235, 1235 then in column 3 values must be sequence of 2345, 2345 and if column 2 contains 6789, 6789... (5 Replies)
Discussion started by: as7951
5 Replies

2. Shell Programming and Scripting

Filter tab file based on column value

Hello I have a tab text file with many columns and have to filter rows ONLY if column 22 has the value of '0', '1', '2' or '3' (out of 0-5). If Column 22 has value '0','1', '2' or '3' (highlighted below), then remove anything less than 10 and greater 100 (based on column 5) AND remove anything... (1 Reply)
Discussion started by: nans
1 Replies

3. Shell Programming and Scripting

Filter Row Based On Max Column Value After Group BY

Hello Team, Need your expertise on following: Here is the set of data: C1|4|C1SP1|A1|C1BP1|T1 C1|4|C1SP2|A1|C1BP2|T2 C2|3|C2SP1|A2|C2BP1|T2 C3|3|C3SP1|A3|C3BP1|T2 C2|2|C2SP2|A2|C2BP2|T1 I need to filter above date base on following two steps: 1. Group them by column 1 and 4 2.... (12 Replies)
Discussion started by: angshuman
12 Replies

4. Shell Programming and Scripting

Check first column - average second column based on a condition

Hi, My input file Gene1 1 Gene1 2 Gene1 3 Gene1 0 Gene2 0 Gene2 0 Gene2 4 Gene2 8 Gene3 9 Gene3 9 Gene4 0 Condition: If the first column matches, then look in the second column. If there is a value of zero in the second column, then don't consider that record while averaging. ... (5 Replies)
Discussion started by: jacobs.smith
5 Replies

5. Shell Programming and Scripting

ksh : Building an array based on condition result

I want to build an Errorlog. I would like to build an array as I move through the if statements and print the array once all error conditions have been defined. The results need to be comma delimited. tsver will be static "1.9.6(2)" other vars $prit $lt $rt can have the same or a different... (1 Reply)
Discussion started by: popeye
1 Replies

6. Shell Programming and Scripting

awk filter based on column value (variable value)

Hi, I have a requirement to display/write the 3rd column from a file based on the value in the column 3. Ex: Data in the File (comma delimited) ID,Value,Description 1,A,Active 1,I,Inactive 2,S,Started 1,N,None 2,C,Completed 2,F,Failed I need to first get a list of all Unique IDs in... (7 Replies)
Discussion started by: kiranredz
7 Replies

7. Shell Programming and Scripting

Sum Of Column Based On Column Condition

Discussion started by: siramitsharma
2 Replies

8. Shell Programming and Scripting

to add special tag to a column based on column condition

Hi All, I have following html code <TR><TD>9</TD><TD>AR_TVR_TBS </TD><TD>85000</TD><TD>39938</TD><TD>54212</TD><TD>46</TD></TR> <TR><TD>10</TD><TD>ASCV_SMY_TBS </TD><TD>69880</TD><TD>33316</TD><TD>45698</TD><TD>47</TD></TR> <TR><TD>11</TD><TD>ARC_TBS ... (9 Replies)
Discussion started by: ckwan
9 Replies

9. Shell Programming and Scripting

printing in certain column based on some result

hii every one can anybody help me writing shell script with this, i have a file ... amit arun vivek and i want to read something from the user and print next to amit or arun in certain column.. like amit 23-wall street 2000 arun 34343 vivek 4758 is... (6 Replies)
Discussion started by: kumar_amit
6 Replies

10. Shell Programming and Scripting

filter based on column value

I have a file with colon separated values.. the sample is attached below. No of fields in each record/line is dependent on the value of field53. What I need to do is to design a special filter based on specific requirement of some match of values in particular column or combination of columns. ... (2 Replies)
Discussion started by: rraajjiibb
2 Replies
Login or Register to Ask a Question