Earlier I asked a question under Solaris, which I got great help... thanks.
Although I got the script working for what it really needed to do, I am looking for a bit of help to change the output for nicer reading.
my script gets a list of zones under a global-zone and puts this to a text file e.g
/newpool/server1
/testpool/server2
### get the zone admin list
zoneadm list -iv | awk '{ print $4 }' | awk ' length>3 ' | grep -v "PATH" | sort >> $ZONES
in a while loop I output the zones and then show, under root, what reboots have been set up (to see if any have been hashed out)
in my loop I echo the zone appending another text file
while read ZONE
do
echo "$ZONE" >> $MSG
echo "--------------------------------------" >> $MSG
cat $ZONE/root/var/spool/cron/crontabs/root | grep "/shutdown" >> $MSG
echo "\n" >> $MSG
done < "$ZONES"
I want to change the output of echo "$ZONE >> $MSG to remove "/pooltype/" and only echo out the server name.
I have tried adding grep - "//" or "\/\\/" but this works but either does not show any server ("//") or shows the server with pool ("\/\\/")
But I am thinking AWK might be better for what I am trying to do but I can't find anything with awk on how to do this, can anyone suggest how to do this?
I have never used sed so don't know anything about that.
You are doing this on Solaris? Are you using /bin/sh , /bin/ksh or /bin/bash ?
I assume $ZONE contains, eg, /newpool/server1 and you want it to appear as server1 .
In /bin/sh , as it looks like a filepath, use
How about doing all of this in one single awk script only? The following is for showing the concept only; not having access to a solaris system, I can't test my proposal.
means: get field 4 from the zoneadm list if its longer than three chars and does not contain the "PATH" string. Doesn't