Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

awk a file with more that 199 fields

Status
Not open for further replies.

cruel

Programmer
Aug 6, 2001
131
Could one awk a file with more than 199 fields? What is the alternative if not?
 
the alternatives (in order):
1. might be nawk
2. might be /usr/xpg4/bin/awk
3. might be gawk (as the last 'awk' resort) vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Thanks. This is what I have: &quot;HP-UX Release 11i: November 2000&quot;. I do not know if I could have them installed, but I just checked and I do not have any of the three.
 
forget about 'nawk' - this's Sun specific.

Sun's /usr/xpg4/bin/awk' is a POSIX compiant version of awk - find out if HPUX has/is a POSIX compliant 'awk'. It might live under a diff. tree.

If you don't have a POSIX version, then try to get an HPUX port of GNU's awk (gawk) - I think it has less 'limitations' than the other versions -
One of the non-awk alternatives might be 'chopping up' records into smaller pieces and processing it with awk separately. There might be others (not using awk at all). vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
SED seems to be able to handle more fields. if I can sub the FS for the new line &quot;\n&quot; using SED, then I will become dealing with number of records. But, the sub for &quot;\n&quot; somehow does not work (the original FS supposed to be ',').

sed 's/\,/&quot;\n&quot;/g'
sed 's/\,/&quot;\\\n&quot;/g'
etc.

It has not been a productive day. Any suggestions? Thanks
 
tr ',' '\n' < file vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
tr ',' '\n' < file
works. Thanks vgersh99

sed 's/\\,//\\n/'g
might have a typo, but not the single quot before letter 'g'. SED can not parse it. But also thanks marsd.

Have a good weekend
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top