The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Cut the last field 435 Gavea Shell Programming and Scripting 9 03-17-2009 01:04 PM
Retrieve 5th Field to Last Field !! jobbyjoseph UNIX for Dummies Questions & Answers 3 05-16-2007 03:20 AM
Moving Part of a field to another field using AWK rjsha1 Shell Programming and Scripting 5 08-04-2006 05:39 AM
add increment field when first field changes azekry Shell Programming and Scripting 2 11-14-2005 04:21 PM
TTL field??? solvman UNIX for Advanced & Expert Users 11 10-12-2001 12:54 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-05-2001
kristy kristy is offline
Registered User
  
 

Join Date: May 2001
Location: Allentown, PA
Posts: 54
Unhappy awk sub-field?

Hi all.
I'm trying to teach myself how to use awk from various on-line sources in order to accomplish a specific task. However, I am scratching my head over this:

the fields in each record are seperated by commas
one field is the date, which is currently like 10/4/2001
I would like it padded with zeros without the slashes, like 10042001

Is there a way to specify a field seperator within a field? that is to say, break down the field into sub-fields? Or am I barking up the completely wrong tree?

thanks,
kristy
  #2 (permalink)  
Old 10-05-2001
rwb1959's Avatar
rwb1959 rwb1959 is offline
Registered User
  
 

Join Date: Aug 2001
Location: Virginia, USA
Posts: 438
Try the split() function...

The split() function has the syntax:
split(<string>,<array>,[<field separator>])

This function takes a string with n fields and stores the fields into array[1], array[2], ... , array[n]. If the optional field separator is not specified, the value of FS (normally space and tab) is used. For example, suppose we have a field of the form:


AWK just takes a bit of getting used to but once you do,
there is little you can't do with it

A great online reference:
http://vectorsite.tripod.com/tsawk0.html
  #3 (permalink)  
Old 10-05-2001
rwb1959's Avatar
rwb1959 rwb1959 is offline
Registered User
  
 

Join Date: Aug 2001
Location: Virginia, USA
Posts: 438
I keep forgetting... the angle brackets get eaten

The split() function has the syntax:
split(string, array, [field separator])

Note the field separator is optional (in [] brackets).
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:54 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0