Search the web
Sign In
New User? Sign Up
geeksthatgawk · for GNU Awk questions & discussions
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Want your group to be featured on the Yahoo! Groups website? Add a group photo to Flickr.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Re: [Geeks that Gawk] Record field manipulation   Message List  
Reply | Forward Message #64 of 221 |
Hi Kevin,

two possibilities that come to mind are:

{ for ( i = 4; i <= NF; i++ ) printf( "%s ", $i ); printf( "\n" ) }

or if you always know exactly what the lengths of your first three
fields will be
(eg. $4 will always start at column 16):

{ printf( "%s\n", substr( $0, 16 ) ) }


Regards,

Maartens

-----Original Message-----
From: Kev Smith [mailto:kevin.smith@...]
Sent: 30 April 2003 11:20
To: geeksthatgawk@yahoogroups.com
Subject: [Geeks that Gawk] Record field manipulation


Hi guys,

I have a record that will always start with the format :

"Mnt D HH:MM:SS data data data"

I would like to strip the first three fields,and put the rest of the
string into a shell variable. I have tried different ways, E.G
printf, index, substr but I just cant seem to get it right. It would
be nice if there was an implementation of BEGIN;{FS=" ";printf "%
s\n",$4,the rest of the fields in the record}. Am I missing something?

Thanks all who read this!

Kev.

Unix sys admin.


------------------------ Yahoo! Groups Sponsor
---------------------~-->
Get 128 Bit SSL Encryption!
http://us.click.yahoo.com/xaxhjB/hdqFAA/bW3JAA/saFolB/TM
---------------------------------------------------------------------~
->

To unsubscribe from this group, send an email to:
geeksthatgawk-unsubscribe@yahoogroups.com



Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/





Wed Apr 30, 2003 12:31 pm

lourenwm@...
Send Email Send Email

Forward
Message #64 of 221 |
Expand Messages Author Sort by Date

Hi Kevin, two possibilities that come to mind are: { for ( i = 4; i <= NF; i++ ) printf( "%s ", $i ); printf( "\n" ) } or if you always know exactly what the...
Maartens Lourens (WMR)
lourenwm@...
Send Email
Apr 30, 2003
12:31 pm

Thank you Maartens. ... [Non-text portions of this message have been removed]...
Smith, Kevin
sync24uk
Offline Send Email
Apr 30, 2003
1:05 pm

... If the data is separated by single spaces (as it seems to be from your example), then you could use cut: $ echo "Mnt D HH:MM:SS data data data" | cut -d" "...
Peter S Tillier
peter_tillier
Offline Send Email
Apr 30, 2003
10:24 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help