- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- scripting advice
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2001 06:41 AM
01-11-2001 06:41 AM
I am developing an interactive monitor script. It works fine, but I am looking for a more subtle use of awk/sed in the disp() function.
I am hoping to replace the amount of greping being done.
Is there a better way ??
Thanks for any help
Steve
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2001 06:57 AM
01-11-2001 06:57 AM
Re: scripting advice
You could combine the 2 first 'grep' into one:
grep "LV Name" /tmp/vgout | awk -F/ '{print $3,$4}' | read vgp lvgp
My 2 cents,
Dan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2001 07:04 AM
01-11-2001 07:04 AM
Re: scripting advice
Another line, reading:
echo $vgp $lvgp $mirr1 $stat1 | awk '{printf " %-10s %-10s %-10s %-10s\n",$1, $2, $3, $4}'
could be replaced with:
printf " %-10s %-10s %-10s %-10s\n" $vgp $lvgp $mirr1 $stat1
That makes 4 cents !! ;7)
Dan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2001 07:10 AM
01-11-2001 07:10 AM
SolutionYou could use the 'line search' feature of 'awk' to find all the strings you're looking for in displ. Instead of running 4 'grep' and 4 'awk' programs, you could combine this in one simple 'awk' outputting 4 values that is piped into a read statement.
6 cents, still far from a full buck !
Dan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2001 07:23 AM
01-11-2001 07:23 AM
Re: scripting advice
here my version of the function displ()
displ()
{
/usr/sbin/lvdisplay -v $b 2>/dev/null | awk '{
if($0 ~ "LV Name")
{
split($0, a, "/");
vgp=a[3];
lvgp=a[4];
}
if($0 ~ "LV Status")
{
if($3 == "available/syncd")
status="Good";
else
status="Bad";
}
if($0 ~ "Mirror copies")
{
if($3 == "1")
mirror="Yes";
else
mirror="No";
printf(" %-10s %-10s %-10s %-10s\n", vgp, lvgp, mirror, status);
}
}'
}
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2001 09:38 AM
01-11-2001 09:38 AM
Re: scripting advice
- looks good to me
Thanks for your help
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2001 07:00 AM
01-12-2001 07:00 AM
Re: scripting advice
Any time your are taking output from grep and piping to awk, the grep can be omitted. (Maybe a rare case where it can not, but I have never seen any...)
I.E.
ps -ef|grep inetd|awk '{print $2}
can be replaced with
ps -ef|awk '/"inetd"/ {print $0}'
NOTE: Certain shells will give you the awk process as well.....But I think you get the point....
Best regards,
Shannon
PS. O'Reilly and Associates puts out a great book on sed and awk. If you dont have it, it is definately worth the $30 bucks or so!