Code Comments
Programming Forum and web based access to our favorite programming groups.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.
Post Follow-up to this messageEd Morton <morton@lsupcaemnt.com> wrote in message news:<chl8u2$emg@netnews.proxy.lucent.co
m>...
> 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.
Post Follow-up to this message
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.
Post Follow-up to this messageEd Morton <morton@lsupcaemnt.com> wrote in message news:<chl8u2$emg@netnews.proxy.lucent.co
m>...
> 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.
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.