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?

2

1 Answer 1

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.

3
  • Don't forget to vote on the questions and answers you found helpful!
    – Wildcard
    Oct 23, 2017 at 20:34
  • How do I vote for Mark Plotnick's answer? It is in a comment.
    – Marinaio
    Oct 23, 2017 at 20:41
  • Vote for the question/answer that he linked to, of course.
    – Wildcard
    Oct 23, 2017 at 20:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .