Hi all,
I have a data file from which i would like to extract only certain fields, which are not adjacent to each other. Following is the format of data file (data.txt) that i have, which has about 6 fields delimited by "|"
HARRIS|23|IT|PROGRAMMER|CHICAGO|EMP
JOHN|35|IT|JAVA|NY|CON
CHRIS|45|HR|ACCOUNT|NJ|EMP
JUDY|32|HR|RECRUIT||EMP
As you can see, there are 6 fields delimited by "|". All i want from this file are the 1,3,5,6 fields separated by the "|" delimiter. So, after extraction, i would like the file to look as
HARRIS|IT|CHICAGO|EMP
JOHN|IT|NY|CON
CHRIS|HR|NJ|EMP
JUDY|HR||EMP
How can i do this using AWK? or which ever utility that would help to achieve this? Remember there can be a null value in the field as could be seen in the last line of the file.
Any help would be greatly appreciated.
Thanks,
Harris.