UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old March 2nd, 2005, 09:35 AM
tqlam tqlam is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 19 tqlam User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 21 m 54 sec
Reputation Power: 0
Can grep search a specific column?

I need to grep a specific column from input with multiple columns. See sample in below:

A B C D E
====================
1 A2 23 A0 A155
2 A1 01 A6 A090
3 A3 10 A1 A015
4 A0 11 A2 A220
5 A4 33 A5 A130
6 A9 06 A3 A085
7 A5 09 AA A060


As above table, I just want to grep A0 from column D, which gives me the following

1 A2 23 A0 A155



Thanks in advance for your help!

Reply With Quote
  #2  
Old March 2nd, 2005, 11:59 AM
jim mcnamara jim mcnamara is offline
......@.........
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jun 2004
Posts: 1,307 jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 4 h 28 m 57 sec
Reputation Power: 48
Code:
 awk '  { if($4=="A0") print $0} '  myfile

Reply With Quote
  #3  
Old March 2nd, 2005, 01:56 PM
guggach guggach is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2004
Location: Middle Europa
Posts: 1,083 guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 Days 19 h 49 m 57 sec
Reputation Power: 9
Quote:
Originally Posted by jim mcnamara
Code:
 awk '  { if($4=="A0") print $0} '  myfile


mmmmhhh
if you anyway want use awk (i personally prefer the faster sed)
show what awk can:
Quote:
awk '$4 ~ /^A0$/' input

__________________
working on Solaris[5-9], preferred languages french and C.

Last edited by guggach : March 2nd, 2005 at 01:59 PM.

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > Can grep search a specific column?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway