greater than a certain value


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting greater than a certain value
# 1  
Old 01-25-2012
greater than a certain value

I have an output from db which looks like :
Code:
row1   row2    row3 
abc      21.1      13
efg       21.1      45
ghi        21.1      75

when I apply following command ( cat my_output.txt | awk {'print $ 4' }

I have following output :
Code:
row3 
13
45
75

now I want to figure out if there is value greater than 70 if yes then create empty file flag.txt
any idea ?
Thanks

Last edited by Franklin52; 01-26-2012 at 03:35 AM.. Reason: Please use code tags for code and data samples, thank you
# 2  
Old 01-26-2012
Code:
awk '{$3 > 70}' my_output.txt > flag.txt

# 3  
Old 01-27-2012
Create an empty file flag.txt if there is value greater than 70, whatever if the file flag.txt is exist or not.
Code:
awk '$3 > 70 {system ("> flag.txt")} ' my_output.txt

# 4  
Old 01-27-2012
hi rdcwayz:
can you please explain the bold section in your logic
Code:
awk '$3 > 70 {system ("> flag.txt")} ' my_output.txt

Thanks

Last edited by Franklin52; 01-28-2012 at 04:22 AM.. Reason: Please use code tags for code and data samples, thank you
# 5  
Old 01-27-2012
system ("> flag.txt") => Invokes a shell and executes the command which is within quotes. And you do know what "> flag.txt" does, right?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Greater than specific number

please let me know how to construct if then else by comparing two numbers if it is greater than 10000. I need to do some specific task executed. can you help me out in shell scripting plz. (6 Replies)
Discussion started by: ramkumar15
6 Replies

2. Shell Programming and Scripting

Find and substitute if greater than.

I have large config-files for an application. The lines have different structure, but some of them contains the parameter 'TIMEOUT=x', where x is an numeric value. I want to change the value for that specific paramater if the value is greater than a specific value (got that?). The timeout-parameter... (3 Replies)
Discussion started by: useless
3 Replies

3. Shell Programming and Scripting

awk to get values greater than

data.txt August 09 17:16 2013 August 09 17:17 2013 August 09 17:19 2013 August 09 17:20 2013 August 09 17:21 2013 August 09 17:22 2013 August 09 17:23 2013 August 09 17:24 2013 to print from a point in this file, to the end of the file, i type: awk '/August 09 17:22/,0' data.txt. ... (1 Reply)
Discussion started by: SkySmart
1 Replies

4. Shell Programming and Scripting

How to search for numbers greater than x?

I have a file with multiple fields, example below File 1: Field 1|Field 2|Field 3|Field 4|Field 5|Field 6|Field 7|100 Field 1|Field 2|Field 3|Field 4|Field 5|Field 6|Field 7|101 Field 1|Field 2|Field 3|Field 4|Field 5|Field 6|Field 7|102 Field 1|Field 2|Field 3|Field 4|Field 5|Field... (4 Replies)
Discussion started by: castrojc
4 Replies

5. Shell Programming and Scripting

find greater than value

Hi I want to find greater than and min value. dategrep() { varlinenum=$1 varSESSTRANS_CL="$(egrep -n "<\/SESSTRANSFORMATIONINST>" tmpsess9580.txt | cut -d":" -f1)" echo $varSESSTRANS_CL } dategrep 8 Output of the above command is: I want to find out greater than 8 and... (9 Replies)
Discussion started by: tmalik79
9 Replies

6. Shell Programming and Scripting

Problem with Greater Than Or Equal To

BASH problem with IS GREATER THAN OR EQUAL TO. I have tried a dozen variations for this IF statement to work with IS GREATER THAN OR EQUAL TO. My code below WORKS. array=( $( /usr/bin/sar -q 1 30 |grep Average |awk '{print $2,$3}' ) ) nthreads="${array}" avproc="${array}" if && ; then ... (6 Replies)
Discussion started by: diex
6 Replies

7. UNIX for Dummies Questions & Answers

Print lines which are greater than

I have a file which has a list of titles and then 14 lines afterwards. I need to find the 1 through 14 lines which are greater than 15k and print the title and the line which matched. Sample before: ABC.CDE.NORTH.NET 1:18427 2:302 3:15559 4:105 5:5 6:2 7:2 8:2 9:4 10:2 11:17 12:2... (3 Replies)
Discussion started by: numele
3 Replies

8. Shell Programming and Scripting

AWK greater than?

Sorry for such a basic question, but I have spent hours trying to work this out! I need an awk command (or similar) that will look at a text file and output to the screen if the 4th column of each line has a value greater than or equal to x. data.txt This is the 1 line This is the 2 line This... (6 Replies)
Discussion started by: dlam
6 Replies

9. Shell Programming and Scripting

greater than less than in case

Hi , I want to do the following: i=6 case $i in -lt 10) echo Period=10 ;; -gt 10 && -lt 15) echo Period-15 ;; >15 && <20) echo Period=20 ;; >20 && <30) ... (2 Replies)
Discussion started by: sars
2 Replies

10. Shell Programming and Scripting

Greater Than

Hello every one! I need a little help. I would like to know if there is someway I can use a "greater than" condition in a shell script. #!/usr/bin/sh _curTime=`date +%H%M` if && then echo "$_curTime" fi I know that "<" and ">" is to input and output to a file I just wanted... (2 Replies)
Discussion started by: Lem2003
2 Replies
Login or Register to Ask a Question