Home > Archive > AWK > September 2004 > awk tab delimited file parsing
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
awk tab delimited file parsing
|
|
|
| I have a file containing data separated by tabs and it spans many
lines. I want to extract only certain fields from each line.
Example:
data1 data2 data3 data4
data1 data2 data3 data4
....
....
I only want to extract data2 and data4 from each line. I know that
awk is capable of this but don't know how. Any comments and or
suggestions would be helpful. Thanks, Monte.
| |
|
| Ed Morton <morton@lsupcaemnt.com> wrote in message news:<chl8u2$emg@netnews.proxy.lucent.com>...
> monte wrote:
>
> awk -F"\t" '{print $2, $4}' file
>
> If the only spaces in the file are tabs, you don't even need the -F"\t".
>
> Ed.
Your solution worked, even for my second posting. Thanks for
responding so soon Ed, I appreciate it. Monte.
| |
| Ed Morton 2004-09-13, 8:55 am |
|
monte wrote:
> I have a file containing data separated by tabs and it spans many
> lines. I want to extract only certain fields from each line.
> Example:
>
> data1 data2 data3 data4
> data1 data2 data3 data4
> ...
> ...
>
> I only want to extract data2 and data4 from each line. I know that
> awk is capable of this but don't know how. Any comments and or
> suggestions would be helpful. Thanks, Monte.
awk -F"\t" '{print $2, $4}' file
If the only spaces in the file are tabs, you don't even need the -F"\t".
Ed.
| |
|
| Ed Morton <morton@lsupcaemnt.com> wrote in message news:<chl8u2$emg@netnews.proxy.lucent.com>...
> monte wrote:
>
> awk -F"\t" '{print $2, $4}' file
>
> If the only spaces in the file are tabs, you don't even need the -F"\t".
>
> Ed.
Your solution worked, even for my second posting. Thanks for
responding so soon Ed, I appreciate it. Monte.
|
|
|
|
|