Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
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.

Report this thread to moderator Post Follow-up to this message
Old Post
monte
09-10-04 08:55 PM


Re: awk tab delimited file parsing
Ed 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.

Report this thread to moderator Post Follow-up to this message
Old Post
monte
09-12-04 01:55 AM


Re: awk tab delimited file parsing

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.

Report this thread to moderator Post Follow-up to this message
Old Post
Ed Morton
09-13-04 01:55 PM


Re: awk tab delimited file parsing
Ed 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.

Report this thread to moderator Post Follow-up to this message
Old Post
monte
09-13-04 08:56 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

AWK archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:06 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.