"grep" will not help you (at least not "grep" alone), because grep filters lines with some patterns in it from a text - nothing less, nothing more. It can either display these filtered lines or count them, but that's it.
But as luck will have it, there are more tools in the Unix toolbox than just "grep" and solving your problem is easy:
In this case you have to filter certain parts of the lines. You can use sed, awk or similar tools for this, but i prefer pure shell code, as this runs by far fastest (i simulate your utility by a simple "cat" and a here-document, which will give the output. Replace this with your original command):
The CPU count is a little more tricky, because you have to sum. Use "awk" for such things:
The next is a combination of line filter and cutting some text from the line. You can use "sed" for such things:
The last one is of the same form (line filter plus text cutting), hence the same approach:
To get the number of hdisks is a problem without knowing which hdisks you have: IDE disks are usually named differently than SCSI (SAS) disks, LUNs using one of the many FC-technologies (SDD, Multipath, Powerpath, and so on) often have even several names for the same disk (each way to the fabric gets its own name), etc..
Tell us, which disks you have or expect and we can tell you how to scan for these.
i have this line of code that looks for the same file if it is currently running and returns the count.
`ps -eaf -o args | grep -i sfs_pcard_load_file.ksh | grep -v grep | wc -l`
basically it is assigned to a variable
ISRUNNING=`ps -eaf -o args | grep -i sfs_pcard_load_file.ksh |... (6 Replies)
I have a question that I am at a loss to solve. I have 3 column tab-separated data, such as:
abs nmod+n+n-commitment-n 349.200023
abs nmod+n+n-a-commitment-n 333.306429
abs into+ns-j+vn-pass-rb-divide-v 295.57316
abs nmod+n+ns-commitment-n 182.085018
abs nmod+n+n-pledge-n ... (2 Replies)
below is an extract from my file and I am trying to use Awk and grep and a while loop to pull infomation from under neath "HBA WWN=".HBA WWN=" reoccurs all over the file but the 100000c.....number are unique and I want to be able to pull and reference specifi information under this header ever time... (2 Replies)
Hi Guys,
I need to set the value of $7 to zero in case $7 is NULL. I've tried the below command but doesn't work. Any ideas. thanks guys.
MEM=`ps v $PPID| grep -i db2 | grep -v grep| awk '{ if ( $7 ~ " " ) { print 0 } else { print $7}}' `
Harby. (4 Replies)
I have this working ksh, and it returns like below:
LOGICAL VOLUME: prod_2048_005 VOLUME GROUP: prod1vg
TYPE: raw WRITE VERIFY: off
PHYSICAL VOLUME: hdisk108 VOLUME GROUP: prod1vg
TOTAL PPs: 1023 (130944 megabytes) VG DESCRIPTORS: 1
USED PPs: 904 (115712 megabytes) MAX REQUEST: 1 megabyte... (1 Reply)
Hiya all ... i am a newbie to UNIX,
Just want to knwo what this command does:
/sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'
I think, 'grep shows the line with 'inet addr' (which is the 2nd line, displaying the IP Address, Broadcast Address and Subnet Mask) ... Is... (8 Replies)
Hi,
I'm a oracle DBA with little knowledge of Unix.
I wanted to write some shell scripts which will be helpful for DBA's regular activity.
As i'm a new to oracle with unix can any plese tell me what are all the activities can be done throgh Unix Shell Scripts also suggest me how to learn... (1 Reply)
from the man page of su:
EXAMPLES
Example 1: Becoming User bin While Retaining Your Previously
Exported Environment
To become user bin while retaining your previously exported
environment, execute:
example% su bin
Example 2: Becoming User bin and ... (4 Replies)