![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Awk - Working with fixed length files | ambroze | Shell Programming and Scripting | 3 | 05-21-2008 06:32 PM |
| What the command to find out the record length of a fixed length file? | tranq01 | UNIX for Dummies Questions & Answers | 3 | 10-19-2007 11:16 AM |
| Join two fixed length Files in Unix | gharikrishnan | Shell Programming and Scripting | 6 | 03-21-2007 09:43 AM |
| sort on fixed length files | sach_in | Shell Programming and Scripting | 6 | 10-26-2006 06:37 AM |
| creating a fixed length output from a variable length input | r1500 | Shell Programming and Scripting | 2 | 12-03-2003 09:09 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
Awk with fixed length files
Hi Unix Champs,
I want to awk on a fixed length file. Instead if the file was a delimited file, then I could have used -F and then could have easily done manipulation on the fields. How do i do the same in case of fixed length file? Thanks in Advance. Regards. |
| Forum Sponsor | ||
|
|
|
|||
|
There are going to be a lot of manipulations only if couple of fields' values.
Now if the file was a delimited, i could have written something like awk '$2=something && $3=somthingelse { some action }' But now since the file is fixed length, a lot of processing processing time will be wasted just on substring and then check wheten to perform the acton. Any solution? |
|
||||
|
Quote:
If you must use awk on a fixed field file, maybe you could insert delimiters first: Code:
$ cat input
111111111122222222223333333333
aaaaaaaaaabbbbbbbbbbcccccccccc
qqqqqqqqqqggggggggggtttttttttt
$ sed 's/\(.\{10\}\)\(.\{10\}\)\(.\{10\}\)/\1-\2-\3/' < input
1111111111-2222222222-3333333333
aaaaaaaaaa-bbbbbbbbbb-cccccccccc
qqqqqqqqqq-gggggggggg-tttttttttt
$
|
||||
| Google The UNIX and Linux Forums |