The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 !!

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-13-2008
NetJones's Avatar
NetJones NetJones is offline
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 | ???
  #2 (permalink)  
Old 05-13-2008
Smiling Dragon's Avatar
Smiling Dragon Smiling Dragon is offline Forum Advisor  
Disorganised User
  
 

Join Date: Nov 2007
Location: New Zealand
Posts: 922
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
  #3 (permalink)  
Old 05-13-2008
NetJones's Avatar
NetJones NetJones is offline
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.
  #4 (permalink)  
Old 05-13-2008
NetJones's Avatar
NetJones NetJones is offline
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?
  #5 (permalink)  
Old 05-13-2008
NetJones's Avatar
NetJones NetJones is offline
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 }'
  #6 (permalink)  
Old 05-13-2008
Annihilannic Annihilannic is offline Forum Advisor  
  
 

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

Code:
awk '/061007/ { print $1 }'
Closed Thread

Bookmarks

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:20 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0