LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-15-2010, 11:00 AM   #1
cliffyao
LQ Newbie
 
Registered: Oct 2009
Posts: 27

Rep: Reputation: 15
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
 
Old 01-15-2010, 12:29 PM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
awk question on handling *.CSV "text fields" in awk jschiwal Programming 8 05-27-2010 07:23 AM
A data parsing problem - AWK indiancosmonaut Programming 1 02-24-2009 11:34 AM
sed, awk - solution for filtering logs cmeyer Linux - Software 8 10-11-2008 02:01 PM
awk/perl script for extract data mruknown1 Linux - Newbie 2 09-11-2007 05:42 AM
iptables packet data filtering firewall <Ol>Origy Linux - Networking 1 08-15-2005 07:07 AM


All times are GMT -5. The time now is 12:07 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration