- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: grep and calculating # of entries
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
Discussions
Discussions
Forums
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
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
тАО05-22-2002 11:29 AM
тАО05-22-2002 11:29 AM
Sometime my file will contain the following entries:
vgcreate vg01
createVG vg01
createVG vg01
vgcreate vg02
createVG vg02
vgcreate vg03
I want to calculating # of occurences of vgcreate and createVG for every disk:
e.g.
tmp=`grep -e "^vg*.* $VGNAME" $CMD |wc -l`
The above grep searches only for vgcreate, does anyone know how can I add 'or' and also search for createVG?
Thanks guys!
Solved! Go to Solution.
- Tags:
- grep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-22-2002 11:38 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-22-2002 11:38 AM
тАО05-22-2002 11:38 AM
Re: grep and calculating # of entries
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-22-2002 11:41 AM
тАО05-22-2002 11:41 AM
Re: grep and calculating # of entries
egrep '^(vg*|cr*)'
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-22-2002 11:42 AM
тАО05-22-2002 11:42 AM
Re: grep and calculating # of entries
You can do:
# grep -e "^vg" -e "createVG"
...or make this case-insensitive too:
# grep -i -e "^fv -e "createVg"
# ...or:
# grep -i -E '^VGcreate|createvg'
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-23-2002 07:21 AM
тАО05-23-2002 07:21 AM
Re: grep and calculating # of entries
grep -cE "^(vgcreate|createVG) vg01"
But now you have to call it separately for each VG. I am lazy (really lazy), so I would go for making awk(1) count everything all at once: place this into a file (say "counter.awk"):
$1 ~ /^(vgcreate|createVG)/ {totals[$2]++}
END {for (VG in totals) print VG,totals[VG]}
Now, you can run it with
awk -f counter.awk data
and get a report that looks like:
vg01 3
vg02 2
vg03 1
-dlt-
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-23-2002 07:40 AM
тАО05-23-2002 07:40 AM