The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-13-2008
NetJones's Avatar
Registered User
 

Join Date: Mar 2008
Location: Dumaguete, Negros Oriental, P.I.
Posts: 8
Question sed or awk?

I've got an inventory database with eight columns with things like product name, manufacturer, UPC code, etc. on each line. Our PO (purchase order) number is in the first column. I can grep the date and get the full line of data but I would like to strip out everything but the PO number in the first column. What should I pipe the grep command to?

grep 061007 | ???
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 05-13-2008
Smiling Dragon's Avatar
Disorganised User
 
Join Date: Nov 2007
Location: New Zealand
Posts: 674
It sounds like cut would do the job for you, if it's not very nicely delimited, awk can sort you out..
If you get stuck on cut, post a line from your file and we'll find a commandline to get you moving again
Reply With Quote
  #3 (permalink)  
Old 05-13-2008
NetJones's Avatar
Registered User
 

Join Date: Mar 2008
Location: Dumaguete, Negros Oriental, P.I.
Posts: 8
Sample line

PO Date Product Manufacturer UPC Dept Loc Comment

108224 061007 12mm bolt ABC Co. xxxxxxxx Eng Cebu Jason


I want to display just the PO in the first column when doing a query with grep on the date....if I grep 061007 | awk what should I put after awk to get only the PO number back?

Thanks for all your help.
Reply With Quote
  #4 (permalink)  
Old 05-13-2008
NetJones's Avatar
Registered User
 

Join Date: Mar 2008
Location: Dumaguete, Negros Oriental, P.I.
Posts: 8
Question No line delimiters

I tried using cut but there are no line delimiters...I'm guessing awk is needed?
Reply With Quote
  #5 (permalink)  
Old 05-13-2008
NetJones's Avatar
Registered User
 

Join Date: Mar 2008
Location: Dumaguete, Negros Oriental, P.I.
Posts: 8
It works with awk...thanks anyway.

grep 061007 | awk '{ print $1 }'
Reply With Quote
  #6 (permalink)  
Old 05-13-2008
Registered User
 

Join Date: May 2008
Location: Sydney, Australia
Posts: 519
No grep necessary:

Code:
awk '/061007/ { print $1 }'
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 01:17 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0