Sponsored Content
Top Forums Shell Programming and Scripting Filter the column and print the result based on condition Post 302341677 by jhon on Thursday 6th of August 2009 10:52:08 AM
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

TABLESPACE_NAME FILE_NAME TOTALSPACE FREESPACE USEDSPACE Free
------------------------- ------------------------------------------------------- ---------- --------- --------- ----------
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 ]
then
echo "This should print all the rows"
fi

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 ]
then
echo "This should print all the rows"
else
"no Problem"
fi
But i dont want the echo statement , but i want the entire rows


Thanks In Advance
Smilie
 

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. Shell Programming and Scripting

Sum Of Column Based On Column Condition

I have a following inputfile MT,AP,CDM,TTML,MUM,GS,SUCC,3 MT,AP,CDM,TTSL,AP,GS,FAIL,9 MT,AP,CDM,RCom,MAH,GS,SUCC,3 MT,AP,CDM,RTL,HP,GS,SUCC,1 MT,AP,CDM,Uni,UPE,GS,SUCC,2 MT,AP,CDM,Uni,MUM,GS,SUCC,2 TTSL,AP,GS,MT,MAH,CDM,SUCC,20 TTML,AP,GS,MT,MAH,CDM,FAIL,10... (2 Replies)
Discussion started by: siramitsharma
2 Replies

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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
SQL::Translator::Filter::Names(3pm)			User Contributed Perl Documentation		       SQL::Translator::Filter::Names(3pm)

NAME
SQL::Translator::Filter::Names - Tweak the names of schema objects. SYNOPSIS
#! /usr/bin/perl -w use SQL::Translator; # Lowercase all table names and upper case the first letter of all field # names. (MySql style!) # my $sqlt = SQL::Translator->new( filename => @ARGV, from => 'MySQL', to => 'MySQL', filters => [ Names => { 'tables' => 'lc', 'fields' => 'ucfirst', }, ], ) || die "SQLFairy error : ".SQL::Translator->error; print($sqlt->translate) || die "SQLFairy error : ".$sqlt->error; DESCRIPTION
SEE ALSO
perl(1), SQL::Translator BUGS
TODO
Name Groups Define a bunch of useful groups to run the name filters over. e.g. all, fkeys, pkeys etc. More Functions e.g. camelcase, titlecase, single word etc. Also a way to pass in a regexp. May also want a way to pass in arguments for the func e.g. prefix. Multiple Filters on the same name (filter order)? Do we actually need this, you could just run lots of filters. Would make adding func args to the interface easier. filters => [ [ 'Names', { all => 'lc' } ], [ 'Names', { tables => 'lc', fields => 'ucfirst', } ], ], Mind you if you could give the filter a list this wouldn't be a problem! filters => [ [ 'Names', all => 'lc' fields => 'ucfirst', ], ], Which is nice. Might have to change the calling conventions for filters. Would also provide an order to run the filters in rather than having to hard code it into the filter it's self. AUTHOR
perl v5.14.2 2012-01-18 SQL::Translator::Filter::Names(3pm)
All times are GMT -4. The time now is 05:34 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy