Comparing each of the value in a column with the known value - in Shell


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Comparing each of the value in a column with the known value - in Shell
# 1  
Old 11-26-2009
Comparing each of the value in a column with the known value - in Shell

I have the column as

2.14%
1.42%
0.64%
0.50%
0.44%
0.38%
0.38%
0.36%
0.35%
0.35%
0.32%
0.32%
0.31%
0.30%
0.30%

I want to find out if any of these values is greater than 75%, is yes then print that value.

Please help me in finding out this.
# 2  
Old 11-26-2009
Try:

Code:
awk -F% '$0 > 75' <filename

# 3  
Old 11-26-2009
Code:
$ gawk 'strtonum($0)>75' file
2.14%
1.42%



---------- Post updated at 02:15 AM ---------- Previous update was at 02:09 AM ----------

bash
Code:
while read -r num
do    
    case "${num%\%}" in
        7[5-9].[0-9][0-9]|[89][0-9].[0-9][0-9]|100) echo $num;;
    esac
done < "file"

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Comparing same column from two files, printing whole row with matching values

First I'd like to apologize if I opened a thread which is already open somewhere. I did a bit of searching but could quite find what I was looking for, so I will try to explaing what I need. I'm writing a script on our server, got to a point where I have two files with results. Example: File1... (6 Replies)
Discussion started by: mitabrev83
6 Replies

2. UNIX for Advanced & Expert Users

Comparing column from two different files

I have two files with different size and formal and want to compare all the values of one of the column in file 1 compared with values of one of the column in file 2 and return the common values as output file. can someone please help if the file size and format are same i am able to get... (4 Replies)
Discussion started by: neuroGen
4 Replies

3. Shell Programming and Scripting

UNIX append field with comparing fields from multiple column

I have a csv dump from sql server that needs to be converted so it can be feed to another program. I already sorted on field 1 but there are multiple columns with same field 1 where it needs to be compared against and if it is same then append field 5. i.e from ANG SJ,0,B,LC22,LC22(0) BAT... (2 Replies)
Discussion started by: nike27
2 Replies

4. Shell Programming and Scripting

Comparing all lines in a column with another is condition is met

Sorry for this noob question, I have file with 4 columns like where columns 2 and 4 have numbers a 55 k 3 b 59 l 3 c 79 m 277 d 255 n 277 e 257 o 267 f 267 p 287 g 290 q 287 h 290 r 287 i 310 s 900 now i want to select only those rows, where values in column 4 are greater than... (4 Replies)
Discussion started by: amits22
4 Replies

5. Shell Programming and Scripting

Joining the files with comparing the first column

Hi, I have two files in the following format. I am trying to compare the first column of both the files and if the values match the rows in file tst6 should be replaced in tst1. File tst1 S00823295|MIDDL|0|MR|019221521A||RL|STD|0|0||E S00862481|ESSEX|0|MR|018163650A||R|STD|0|0||E... (1 Reply)
Discussion started by: nua7
1 Replies

6. UNIX for Dummies Questions & Answers

Comparing two text files by a column and printing values that do not match

I have two text files where the first three columns are exactly the same. I want to compare the fourth column of the text files and if the values are different, print that row into a new output file. How do I go about doing that? File 1: 100 rs3794811 0.01 0.3434 100 rs8066551 0.01... (8 Replies)
Discussion started by: evelibertine
8 Replies

7. Shell Programming and Scripting

comparing column of two different files and print the column from in order of 2nd file

Hi friends, My file is like: Second file is : I need to print the rows present in file one, but in order present in second file....I used while read gh;do awk ' $1=="' $gh'" {print >> FILENAME"output"} ' cat listoffirstfile done < secondfile but the output I am... (14 Replies)
Discussion started by: CAch
14 Replies

8. Shell Programming and Scripting

awk- comparing fields from the same column, finding discontinuities.

Hello, I have a file with two fields. The first field repeats itself for quite a while but the second field changes. What I want to do is to go through the first column until its value changes (and while it doesn't, verify that the second field is in a sequence from 0-15). Example input: ... (13 Replies)
Discussion started by: acsg
13 Replies

9. Shell Programming and Scripting

Comparing two files and printing 2nd column if match found

Hi guys, I'm rather new at using UNIX based systems, and when it comes to scripting etc I'm even newer. I have two files which i need to compare. file1: (some random ID's) 451245 451288 136588 784522 file2: (random ID's + e-mail assigned to ID) 123888 xc@xc.com 451245 ... (21 Replies)
Discussion started by: spirm8
21 Replies

10. Shell Programming and Scripting

Comparing values in column 1

Hi to all, I have the following text within inputfile data1,value1,value2 data1,value3,value2 data1,value5,value6 data2,value1,value2 data2,value3,value4 data3,value1,value2 data3,value3,value4 data4,value1,value2 data4,value3,value4 data4,value5,value6 I would like to... (4 Replies)
Discussion started by: cgkmal
4 Replies
Login or Register to Ask a Question