1

I want to write a one liner on Solaris 11 to check the space in each of the zpools of my systems. The output would look like this...

myzone1 rpool 83%
myzone2 rpool 49%

All the posts I've read say to use the -v switch to pass a shell variable to awk.

Everytime I try I get an error.

This code works. I get the pool and the percentage used.

for i in `zoneadm list -icv|grep running|awk '{print $2}'`; do
    zlogin $i zpool list -H|awk '{print $1" "$5}';
done

I want to add the zonename to this report output. This code does not work for me!

for i in `zoneadm list -icv|grep running|awk '{print $2}'`; do
    zlogin $i zpool list -H|awk -v i="$i" '{print i" "$1" "$5}';
done

Can you help me find where I am making a mistake?

Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255
Marinaio
  • 298

1 Answers1

1

Thanks to this comment:

Related: POSIX awk on Solaris 11Mark Plotnick

I rewrote the code to:

for i in `zoneadm list -icv|grep running|awk '{print $2}'`; do zlogin $i zpool list -H|/usr/bin/nawk -v i="$i" '{print i" "$1" "$5}';done

This works the way I want it to report.

Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255
Marinaio
  • 298