| Author |
How do I parse a numeric string with awk?
|
Earl Frederick
Greenhorn
Joined: Feb 08, 2012
Posts: 1
|
|
I have a string in a data file 120134752 i'd like to separate this string into 3 pieces HHMMSSSSS and print that into
a new file as 3 separated strings as HH MM SSSSS (using a space as separator. I can't find any tips in books or online).
the full record in the file looks like this 3828100291 67037746 309500213 100950 120134752
thanks for any help!
earlb
|
 |
Tim Holloway
Saloon Keeper
Joined: Jun 25, 2001
Posts: 12513
|
|
Welcome to the Ranch, Earl!
I'm out of practice, but awk is based on regex processing, so the easiest way to break a string like HHMMSSSS into components would be to use groupings, like so:
[code]
(\d\d)(\d\d)(\dddd)
[code]
Which would then be mapped to individual variables ($1, $2, $3). Actually, I think that you can map them to named variables, but like I said, I'm really out of practice with AWK.
|
One of the most odious afflictions that Business has inflicted on the modern English language is "pro-active". Most of the time it's simply redundantly used in place of the simple old word "active". And a good deal of the rest of the time it means "You're not overworked enough yet, so go out and find more!"
|
 |
 |
|
|
subject: How do I parse a numeric string with awk?
|
|
|