LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   awk - data filtering question (https://www.linuxquestions.org/questions/linux-newbie-8/awk-data-filtering-question-782403/)

cliffyao 01-15-2010 10:00 AM

awk - data filtering question
 
Hi, All

I have a file like this

chr 746996 C A 48 48 37 25 AAAAAAA
chr 747099 t C 45 45 37 6 c$CCCcc
chr 1003018 g C 36 36 37 20 ccc

I want to extract column 1, 2, 3, 4, 6, 8, 9. Also, I want to those rows in which the elements of column 8 are >=20.

I used

awk '$8>=20 {print $1,$2,$3,$4,$6,$8,$9}' input.txt > out.txt

it can just pick some of the rows where the column8's element >=20 but not all the right columns.

Can anybody help me on this?

I guess the way I used awk is not correct.

Thanks

David the H. 01-15-2010 11:29 AM

Can you give us some examples of lines where it doesn't work properly? It appears to work just fine on the sample you provided.


All times are GMT -5. The time now is 10:44 AM.