INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

> < operators in awk

> < operators in awk

(OP)

Hello,
could someone please explain why in examples below awk with $5>"57" returns red line too? With $5<"57" doesn't.

CODE

$ df -v -g >/tmp/output
$ cat /tmp/output
Filesystem    GB blocks      Used      Free %Used    Iused    Ifree %Iused Mounted on
/dev/hd4           0.50      0.19      0.31   39%    10132    73117    13% /
/dev/hd2           2.25      2.09      0.16   93%    45467    42195    52% /usr
/dev/hd9var        0.44      0.35      0.09   80%     8219    22854    27% /var
/dev/hd3           0.12      0.00      0.12    2%       41    31969     1% /tmp
/dev/hd1           0.06      0.00      0.06    1%        5    14543     1% /home
/dev/hd11admin      0.12      0.00      0.12    1%        5    29133     1% /admin
/proc                 -         -         -    -         -        -     -  /proc
/dev/hd10opt       0.44      0.25      0.19   57%     8956    45165    17% /opt
/dev/livedump      0.25      0.00      0.25    1%        4    58200     1% /var/adm/ras/livedump
$ awk 'NR==1 || $5>"51"' /tmp/output
Filesystem    GB blocks      Used      Free %Used    Iused    Ifree %Iused Mounted on
/dev/hd2           2.25      2.09      0.16   93%    45467    42195    52% /usr
/dev/hd9var        0.44      0.35      0.09   80%     8219    22854    27% /var
/dev/hd10opt       0.44      0.25      0.19   57%     8956    45165    17% /opt
$ awk 'NR==1 || $5>"57"' /tmp/output
Filesystem    GB blocks      Used      Free %Used    Iused    Ifree %Iused Mounted on
/dev/hd2           2.25      2.09      0.16   93%    45467    42195    52% /usr
/dev/hd9var        0.44      0.35      0.09   80%     8219    22854    27% /var
/dev/hd10opt       0.44      0.25      0.19   57%     8956    45165    17% /opt
$ awk 'NR==1 || $5<"57"' /tmp/output
Filesystem    GB blocks      Used      Free %Used    Iused    Ifree %Iused Mounted on
/dev/hd4           0.50      0.19      0.31   39%    10132    73117    13% /
/dev/hd3           0.12      0.00      0.12    2%       41    31969     1% /tmp
/dev/hd1           0.06      0.00      0.06    1%        5    14543     1% /home
/dev/hd11admin      0.12      0.00      0.12    1%        5    29133     1% /admin
/proc                 -         -         -    -         -        -     -  /proc
/dev/livedump      0.25      0.00      0.25    1%        4    58200     1% /var/adm/ras/livedump
$ ( awk 'NR==1 || $5>"57"' /tmp/output ; awk '$5<"57"' /tmp/output )|sort|cksum
905655793 825
$ sort /tmp/output|cksum
905655793 825
$ awk 'NR==1 || $5=="57"' /tmp/output
Filesystem    GB blocks      Used      Free %Used    Iused    Ifree %Iused Mounted on
$ awk 'NR==1 || $5~/^57/' /tmp/output
Filesystem    GB blocks      Used      Free %Used    Iused    Ifree %Iused Mounted on
/dev/hd10opt       0.44      0.25      0.19   57%     8956    45165    17% /opt
$ 

RE: > < operators in awk


Because the fifth field ($5) include the percent sign and your condition $5<"57" does not.
3eyes

----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

RE: > < operators in awk

(OP)
ok, I used such workaround

df -v -g|sed s/%/\ abc\ /g|awk -va=94 'NR==1 || $5>a'|sed s/\ abc\ /%/g

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close