pull out rows with specific criteria


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting pull out rows with specific criteria
# 1  
Old 05-16-2012
pull out rows with specific criteria

Hi,
I have a file with multiple columns and for column 5 I want to extract that row into another file if it is equal to or greater than a certain value.

For example:

Code:
FAR  4  5  7  LOP
GAT  3  3  3  POL

I want values that are greater than 5 for column 4. So the final file will look like this.

Code:
FAR  4  5  7  LOP

Thanks

Phil
# 2  
Old 05-16-2012
This is exactly the sort of problem awk was made for.
Code:
awk '$4 > 5' inputfile > outputfile

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Only print specific xml values that meet two criteria in python

I have a large XML file that I want to parse, and only print one specific value if two values are met. This is the code so far: #!/usr/local/bin/python import xml.etree.ElementTree as ET tree = ET.parse('onedb-dhcp.xml') root = tree.getroot() # This successfully gets all... (1 Reply)
Discussion started by: brianjb
1 Replies

2. Shell Programming and Scripting

Rows to Columns with match criteria

Hello Friends, I have a input file having hundreds of rows. I want them to translate in to columns if column 1 is same. Input data: zp06 xxx zp06 rrr zp06 hhh zp06 aaa zp06 ggg zp06 qwer zp06 ser zl11 old3 zl11 old4 zl11 old5 zl11 old6 zl11 old7 zm14 luri zm14 body zm14 ucp (9 Replies)
Discussion started by: suresh3566
9 Replies

3. Shell Programming and Scripting

[Solved] How can I pull specific information from PS?

I need to grab information from the output of the ps command. For each line of ps output that contains _progres -b I need to get the word that follows -p. The "-p" can be anywhere after "_progres -b". Using grep to select the correct lines is no problem (e.g. ps -ef|grep "_progres \-b|grep -v... (3 Replies)
Discussion started by: Papa Lee
3 Replies

4. UNIX for Dummies Questions & Answers

delete rows with a criteria

Hi, I would like to know how can I delete rows of a text file if from the 3rd column onwards there is only zeros? Thanks in advance (7 Replies)
Discussion started by: fadista
7 Replies

5. Shell Programming and Scripting

Pull specific lines from long file based on formula

For people who want to pull a number of lines from a long file using a specific formula n (number of iterations in a loop) a (offset number) b (stretch factor) example with n {1..100} for (( n=1; n<101; n++ )); do awk -v n=$n 'NR==a+(b*n)' a=0 b=1 inputfile >>outputfile (2 Replies)
Discussion started by: sgruenwald
2 Replies

6. Shell Programming and Scripting

Extract data based on specific search criteria

I have a huge file (about 2 millions records) contains data separated by “,” (comma). As part of the requirement, I can't change the format. The objective is to remove some of the records with the following condition. If the 23rd field on each line start with 302 , I need to remove that from the... (4 Replies)
Discussion started by: jaygamini
4 Replies

7. Shell Programming and Scripting

Please do help: Perl Script to pull out rows from a CSV file

I have CSV file that contains data in the format as shown below: ABC, 67, 56, 67, 78, 89, 76, 55 PDR, 85, 83, 83, 72, 82, 89, 83 MPG, 86, 53, 54, 65, 23, 54, 75 .. .. .. .. I want to create a script that will pull out the rows from the above sheet and paste it into another CSV file.... (12 Replies)
Discussion started by: pankajusc
12 Replies

8. Shell Programming and Scripting

Pull specific data from repetitive text?

Hi all, I have a bit of a problem with a loop that extracts repetitive text. Running /bin/index executable outputs this text to terminal: testing index 'scanthread'... collected 0 docs, 0.0 MB total 0 docs, 0 bytes total 0.012 sec, 0 bytes/sec, 0.00 docs/sec testing index 'scanpost'...... (6 Replies)
Discussion started by: TECK
6 Replies

9. Shell Programming and Scripting

Deleting specific rows in large files having rows greater than 100000

Hi Guys, I need help in modifying a large text file containing more than 1-2 lakh rows of data using unix commands. I am quite new to the unix language the text file contains data in a pipe delimited format sdfsdfs sdfsdfsd START_ROW sdfsd|sdfsdfsd|sdfsdfasdf|sdfsadf|sdfasdf... (9 Replies)
Discussion started by: manish2009
9 Replies

10. Shell Programming and Scripting

Selecting rows with a specific criteria

Hi, I want a UNIX command that can filter out rows with certain criteria. The file is tab deliminated. Row one is just a value. Basically what I want to do is select based on the name and character at the end (o). So lets lets say i want a row that has WashU and (o) then it would print... (2 Replies)
Discussion started by: phil_heath
2 Replies
Login or Register to Ask a Question