![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to extract a column from two different files in AWK? | solracq | Shell Programming and Scripting | 7 | 04-29-2008 06:21 AM |
| column extract help | cvm | Shell Programming and Scripting | 1 | 04-24-2008 04:19 PM |
| Extract column data from File | sudheshnaiyer | UNIX for Dummies Questions & Answers | 3 | 10-11-2007 09:52 PM |
| extract column based on name | t27 | UNIX for Dummies Questions & Answers | 3 | 08-29-2007 01:04 PM |
| I need to extract last column of a file and compare the values | vukkusila | Shell Programming and Scripting | 4 | 08-04-2007 11:21 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
How to extract only first column from the file
Dear All,
I have a file name pointer.unl. It's contains the information below: O|A|4560333089|PBS|AU1|01/04/2003|30/04/2006|D|IGCD| O|A|4562222089|PBN|AU1|01/02/2006|31/01/2008|D|04065432| O|A|3454d00089|PKR|AU1|01/03/2008||R|sdcdc| I only need to extract first column only which is the "O" column. I tried command below; 1-awk '{print $1}' filename - but it display all the column 2-awk 'Begin {OFS="|"} {print $1}' filename - still showing all the column 3- awk -F| '{print $1}' filename > outfilename - still display all the file comlum Appreciate if somebody can assist me. Rgrds Shahril |
|
||||
|
Well I don't know why the awk statement isn't working, I'm hoping someone will enlighten us both on that matter, but the sed statement is removing the | from each line. It would work just as well to use
Code:
cat unix |tr "|" " "|awk '{print $1}'
I think that if you escape (put a \) in front of the | in your original awk statement that will work as well Code:
cat unix |awk -F\| '{print $1}'
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|