Results 1 to 5 of 5
Hi,
I would like to know how can I select lines based on the information that I have on the 6th column.
My file looks like this:
91102 12684 0 ...
- 03-11-2010 #1Just Joined!
- Join Date
- Mar 2010
- Posts
- 4
extract line based on column information
Hi,
I would like to know how can I select lines based on the information that I have on the 6th column.
My file looks like this:
91102 12684 0 0 2 -9 G G C
91102 12682 12685 12684 1 2 G G A
91101 12680 0 0 2 -9 G G A
91101 12678 12681 12680 2 2 G G A
I want to extract the lines that have in the 6th collumn number 2. So in the end my file should be:
91102 12682 12685 12684 1 2 G G A
91101 12678 12681 12680 2 2 G G A
Thanks in advance.
Thais
- 03-11-2010 #2
This is simple in awk since awk reads a line at a time..
Code:awk '{if ($6 == 2){printf("%s\n", $0);}}' datafileLast edited by gerard4143; 03-11-2010 at 01:50 PM.
Make mine Arch Linux
- 03-11-2010 #3
Or if your more comfortable with bash..
Code:#! /bin/sh while read f do set -- $f if [ "$6" = "2" ] then echo $f fi done < datafile
Make mine Arch Linux
- 03-12-2010 #4Just Joined!
- Join Date
- Nov 2006
- Location
- Hyderabad
- Posts
- 85
Hi i am not gud enough in shell script.
while read f -> will it read line by line ?
set -- $f -> what is the meaning of it ? to what it is set to
- 03-12-2010 #5Just Joined!
- Join Date
- Mar 2010
- Posts
- 4
Thanks!!!


Reply With Quote