Frage

I need to get the value of "Boot Environment Name", "Active Now", "Active On Reboot" from the output of "lustatus" command in Solaris, to figure out if there is any switch in the boot environment.

I'll store the value of Active boot environment in a file, and check if there is any change in boot environment during an upgrade, to perform some operations.

Output of lustatus command will be like this:

bash-3.2# /usr/sbin/lustatus
Boot Environment           Is       Active Active    Can    Copy
Name                       Complete Now    On Reboot Delete Status
-------------------------- -------- ------ --------- ------ ----------
d10                        yes      yes    yes       no     -
d70                        yes      no     no        yes    -
War es hilfreich?

Lösung

Using awk

/usr/sbin/lustatus  | awk 'NR>3&&$3=="yes"{print $1}'

Andere Tipps

how can i put a condition check for the value of "Active now" as "yes", then print only the "Boot Environment Name" in awk command?

this line would do:

yourCmd|awk '$3=="yes"&&$0=$1'

I believe this awk example will help;

/usr/sbin/lustatus | tail -n 2 | awk '{print $1 " " $3 " " $4}'

d10 yes yes
d70 no no
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top