awk don't work in hp-ux 11.11

Hello all!
I have problem in hp-ux 11.11 in awk

I want to grep sar -d 2 1 only 3 column, but have error in awk in hp-ux 11.11

Example:

#echo 123 234 | awk '{print $2}'
123 234

The situattions in commands bdf | awk {print $5}' some...

In hp-ux 11.31 - OK!

How resolve problem

Please post the exact command and error message.

# bdf | awk '{print $5}'
Filesystem          kbytes    used   avail %used Mounted on
/dev/vg00/lvol3    7110656 2231424 4841544   32% /
/dev/vg00/lvol1    1014648   51616  861560    6% /stand
/dev/vg00/lvol8    24576000 9939176 14580152   41% /var
/dev/vg00/lvol7    4096000 1507464 2568352   37% /usr
/dev/vg00/lvol6    2097152  424976 1659704   20% /tmp

I meant awk don't work)

I cannot reproduce this behavior:

bash-2.05$ uname -sr
HP-UX B.11.11
bash-2.05$ bdf | awk '{print $5}'
%used
33%
...

Could you post the output of the following command:

[for /usr/bin/sh or ksh]:

file "$(whence awk)"

[for bash]:

file "$(type -p awk)"

this?

# sh file "$(whence awk)"
bash: whence: command not found
file: invalid multibyte character

/sbin]# file "$(whence awk)"
bash: whence: command not found

that's all!

Did you read my entire post?
Just run the following command on your shell prompt:

file "$(type -p awk)"

Sorry,that:

#/usr/bin/awk:   PA-RISC1.1 shared executable dynamically linked

Hm,
just a shot in the dark, try this:

(export LC_ALL=C; bdf | awk '{print $5}')
# export LC_ALL=C; bdf | awk '{print $5}'
Filesystem          kbytes    used   avail %used Mounted on
/dev/vg00/lvol3    7110656 2231424 4841544   32% /
/dev/vg00/lvol1    1014648   51616  861560    6% /stand
/dev/vg00/lvol8    24576000 9939432 14579896   41% /var
/dev/vg00/lvol7    4096000 1507464 2568352   37% /usr

Could you post the output of this command too:

bdf . | od -cb

OK

[root@omu /sbin]# bdf . | od -cb  
0000000   F   i   l   e   s   y   s   t   e   m
        106 151 154 145 163 171 163 164 145 155 040 040 040 040 040 040
0000020                   k   b   y   t   e   s                   u   s
        040 040 040 040 153 142 171 164 145 163 040 040 040 040 165 163
0000040   e   d               a   v   a   i   l       %   u   s   e   d
        145 144 040 040 040 141 166 141 151 154 040 045 165 163 145 144
0000060       M   o   u   n   t   e   d       o   n  \n   /   d   e   v
        040 115 157 165 156 164 145 144 040 157 156 012 057 144 145 166
0000100   /   v   g   0   0   /   l   v   o   l   8                   2
        057 166 147 060 060 057 154 166 157 154 070 040 040 040 040 062
0000120   4   5   7   6   0   0   0       9   9   3   9   4   3   2
        064 065 067 066 060 060 060 040 071 071 063 071 064 063 062 040
0000140   1   4   5   7   9   8   9   6               4   1   %       /
        061 064 065 067 071 070 071 066 040 040 040 064 061 045 040 057
0000160   v   a   r  \n
        166 141 162 012
0000164

Hm,
I really don't know.

  1. Let's see if the problem is in awk:
echo a b | awk '{print $2}'
  1. bdf:
bdf . | while read a b;do printf '%s\n' "$a";done
# echo a b | awk '{print $2}'
b
bdf . | while read a b;do printf '%s\n' "$a";done
Filesystem
/dev/vg00/lvol8

So awk seems to be working correctly.
Could you post all the input / output (commands and output exactly as you type them in your terminal, do not re-write them, just copy/paste).

I can only reproduce this if the commands were issued in a shell script and the wrong sort of quotes was used. i.e shell substituted $2 for null space.

echo abc cba | awk "{print $2}"
echo abc cba | awk '{print $2}'

abc cba
cba

BTW. Processing the "sar -d 2 1" output is a nightmare because column 1 for the second and subsequent disc is blank. You may need to use "cut" first to get rid of the time column.

Thanks