- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: AWK version in hpux 11.11
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-09-2008 08:14 AM
тАО10-09-2008 08:14 AM
Re: AWK version in hpux 11.11
> OldSchool: did you happen to try the -F and {BEGIN..} methods?
Yes, indeed, they are consistent in HP-UX (11.11) and with GNU's awk (gawk) as I noted. Either Duncan's or Dennis' version work On HP-UX (11.11) or Linux Fedora 9 (GNU Awk 3.1.5) and yield output of "2".
I see the same "1" output using 'gawk' and "2" using HP-UX's 'awk' as noted by the OP.
Warmest Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-09-2008 08:37 AM
тАО10-09-2008 08:37 AM
Re: AWK version in hpux 11.11
123#abc
123#def
running
gawk '{FS="#"; print NF, $FN}' abc'
would get
1 123#abc
2 def
????
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-09-2008 08:50 AM
тАО10-09-2008 08:50 AM
Re: AWK version in hpux 11.11
Using OldSchool's suggested test:
$ cat /tmp/abc
123#abc
123#def
$ gawk '{FS="#"; print NF, $FN}' /tmp/abc
1 123#abc
2 123#def
...by the way, thanks Peter, for posting the '[gon]awk' tests!
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-09-2008 09:12 AM
тАО10-09-2008 09:12 AM
Re: AWK version in hpux 11.11
correcting the typo in OldSchool suggested test
<< '{FS="#"; print NF, $FN}'
>> '{FS="#"; print NF, $NF}'
leads - of course - to the expected results under Solaris10 here:
gawk '{FS="#"; print NF, $NF}' /tmp/abc
1 123#abc
2 def
oawk '{FS="#"; print NF, $NF}' /tmp/abc
1 123#abc
2 def
nawk '{FS="#"; print NF, $NF}' /tmp/abc
2 abc
2 def
nawk -F'#' '{print NF, $NF}' /tmp/abc
2 abc
2 def
oawk -F'#' '{print NF, $NF}' /tmp/abc
2 abc
2 def
gawk -F'#' '{print NF, $NF}' /tmp/abc
2 abc
2 def
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-09-2008 09:25 AM
тАО10-09-2008 09:25 AM
Re: AWK version in hpux 11.11
Yikes, Peter, your eyes are better the mine today. I completely missed the "FN" / "NF" transposition. Here is OldSchool's test (properly):
$ gawk '{FS="#"; print NF, $NF}' /tmp/abc
1 123#abc
2 def
...exactly as he expected it to behave.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-09-2008 04:33 PM
тАО10-09-2008 04:33 PM
Re: AWK version in hpux 11.11
[Chinese]:├и┬░┬в├и┬░┬в├е┬д┬з├е┬о┬╢!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-09-2008 05:32 PM
тАО10-09-2008 05:32 PM
Re: AWK version in hpux 11.11
Since you are new to the forums please read the following about assigning points:
http://forums.itrc.hp.com/service/forums/helptips.do?#33
If you have no further questions about awk/FS, you can also close this thread, indicating you got your answers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-09-2008 07:25 PM
тАО10-09-2008 07:25 PM
Re: AWK version in hpux 11.11
I have motified my awk script, use split instead 'FS' in awk {}.
Thanks for :
=====
"Typically, the field and record separators are defined in the BEGIN procedure because you want these values set before the first input line is read. However, you can redefine these values anywhere in the script. In POSIX awk, assigning a new value to FS has no effect on the current input line; it only effects the next input line"
it continues on to say:
"NOTE:
Prior to the June 1996 release of Bell Labs awk, versions of awk for UNIX did not follow the POSIX standard in this regard. In those versions, if you have not yet referenced an individual field, and you set the field separator to a different value, the current input line is split into fields using the new value of FS.
====
Thanks again !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-09-2008 07:25 PM
тАО10-09-2008 07:25 PM
Re: AWK version in hpux 11.11
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-09-2008 08:47 PM
тАО10-09-2008 08:47 PM
Re: AWK version in hpux 11.11
You can reopen threads by:
http://forums.itrc.hp.com/service/forums/helptips.do?#41