![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| 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 !! |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
||||
|
||||
|
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 | ??? |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
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
|
||||
|
||||
|
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
|
||||
|
||||
|
I tried using cut but there are no line delimiters...I'm guessing awk is needed?
|
|
#5
|
||||
|
||||
|
It works with awk...thanks anyway.
grep 061007 | awk '{ print $1 }'
|
|
#6
|
|||
|
|||
|
No grep necessary:
Code:
awk '/061007/ { print $1 }'
|
|||
| Google The UNIX and Linux Forums |