awk problems on Solaris 
Author Message
 awk problems on Solaris

I am having problems getting two things to work in awk under Solaris
that work fine under FreeBSD:

1.  Command-line variable substitution:

bash$ cat prog
#! /usr/bin/awk -f
{
  if ($2 ~ t1)
    print

Quote:
}

bash$ prog t1="XXX" inputfile  (works under FreeBSD, but not Solaris)

2.  "Do" loops:

do
  getline
while ($1 != "XXX")     (works under FreeBSD, but not Solaris)

Note that the following works under both systems:

while ($1 != "XXX")
  getline

Any ideas??

--
Greg

http://www.*-*-*.com/ ~jupiter3



Wed, 25 Nov 1998 03:00:00 GMT  
 awk problems on Solaris

The FreeBSD version of awk might actually be nawk or gawk.

--

On 22 July, 1996, at 6:00 pm GMT, everyone in the world    
just START HUMMING.  Those who don't know will freak.      



Thu, 26 Nov 1998 03:00:00 GMT  
 awk problems on Solaris

: I am having problems getting two things to work in awk under Solaris
: that work fine under FreeBSD:
:
[snip]
: --
: Greg

: http://www.tgn.net/~jupiter3
:

I may be shooting fpr the over-simplistic, but for some reason Solaris'
default 'awk' link is to 'oawk', you night try specifically calling
'nawk', this may well solve your problem.

Tim Rayburn
Programmer
Earth Science Associates



Thu, 26 Nov 1998 03:00:00 GMT  
 awk problems on Solaris

Quote:

> I am having problems getting two things to work in awk under Solaris
> that work fine under FreeBSD:

> 1.  Command-line variable substitution:

> bash$ cat prog
> #! /usr/bin/awk -f
> {
>   if ($2 ~ t1)
>     print
> }
> bash$ prog t1="XXX" inputfile  (works under FreeBSD, but not Solaris)

> 2.  "Do" loops:

> do
>   getline
> while ($1 != "XXX")     (works under FreeBSD, but not Solaris)

> Note that the following works under both systems:

> while ($1 != "XXX")
>   getline

> Any ideas??

     Just one. Under Solaris, use nawk:

#!/usr/bin/nawk -f

     I'm unable to test this, and I really don't know if it's a viable
suggestion. I only know that, under SunOS 4.1.2, I often get unexpected
results when I inadvertently use awk instead of nawk.

---
Jim Monty

Tempe, Arizona USA



Thu, 26 Nov 1998 03:00:00 GMT  
 awk problems on Solaris

Quote:

>I am having problems getting two things to work in awk under Solaris
>that work fine under FreeBSD:

[snip]

Using nawk under Solaris solved the problems.  Thanks to all who
posted/e-mailed.

--
Greg

http://www.tgn.net/~jupiter3



Fri, 27 Nov 1998 03:00:00 GMT  
 awk problems on Solaris

Try something like;

awk -F: '$1 == "'$variable'" {printf("%-10s $10s\n",$1,$80)}'

where "variable" is a shell assignment.



Sat, 28 Nov 1998 03:00:00 GMT  
 awk problems on Solaris


Quote:
> Subject: Re: awk problems on Solaris
> Try something like;
> awk -F: '$1 == "'$variable'" {printf("%-10s $10s\n",$1,$80)}'
> where "variable" is a shell assignment.

You might want to put double quotes around the $variable in case the
value that gets substituted contains spaces.

awk -F: '$1 == "'"${variable}'"" {printf("%-10s $10s\n",$1,$80)}'

           Brian Kelly             | Ya know, there's a million fine lookin'
                                   | women in the world, dude; but they don't

http://WWW.IS.Montclair.edu/~Kelly | 'em just cheat on ya.      -- Silent Bob



Sat, 28 Nov 1998 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. awk script not working on SUN Solaris

2. Limit for the Line handle by NAWK/AWK on SOLARIS 2.5.7

3. Awk does not work on Solaris...

4. awk on Solaris 2.5

5. How to determine awk version number under Solaris and IRIX

6. Old awk on Solaris 2.6 & no error

7. awk script fails on solaris 2.4

8. x86 Solaris vs Sparc Solaris

9. Dynamic linking on Solaris 2.7 (Solaris 7)

10. Different behaviour in solaris 5.6 and solaris 5.7

11. Tcl/Tk8.0p2 weird behaviour under Solaris 2.5.1 and Solaris 2.6

12. Problem loading shared library under Solaris 2.51

 

 
Powered by phpBB® Forum Software