Need help with filtering

Hi!!

I have a bit of a task here and filtering/scripting not my strongest. I have to collect info of approx 1100 hdiskpower.so i have appended all the hdisk into a text file and i need it to run the command lscfg -vl to confirm if the drive is symmetrix. here's what i have so far

at hdiskpower | xargs -i lscfg -vl {} |grep SYMMETRIX

Now this works fine but I can't seem to figure out how to get the hdiskpower line in this list as well.

Now if you can also help me with one more thing I would greatly appreciate it!
once i collect up all the info of the drives that are symmetrix i need to calculate all the disk space that these drives have (total space) I believe that I am going to use the command <getconf DISK_SIZE /dev/hdiskpower$>

Like I'm saying I need help!

Thanks in advance!

Hi!!

I have a bit of a task here and filtering/scripting not my strongest. I have to collect info of approx 1100 hdiskpower.so i have appended all the hdisk into a text file and i need it to run the command lscfg -vl to confirm if the drive is symmetrix. here's what i have so far

at hdiskpower | xargs -i lscfg -vl {} |grep SYMMETRIX

Now this works fine but I can't seem to figure out how to get the hdiskpower line in this list as well.

Now if you can also help me with one more thing I would greatly appreciate it!
once i collect up all the info of the drives that are symmetrix i need to calculate all the disk space that these drives have (total space) I believe that I am going to use the command <getconf DISK_SIZE /dev/hdiskpower$>

Like I'm saying I need help!

Thanks in advance!

It would help a bit to know what that file looks like. If you want a precise answer you might consider asking precise questions and state your preconditions precisely.

Maybe something like the following is what you look for. It will most probably need some refining, but should work as a basis on which to build your own:

typeset    hdpwr=""
typeset -i hdsize=0
typeset -i hdsum=0

exec 3>/path/to/resultfile

print -u3 "---- SYMMETRIX disks / sizes at $(date)"
cat file-with-hdisks | while read hdpwr ; do
     if [ $(lscfg -vl $hdpwr | grep -c SYMMETRIX) -ge 1 ] ; then
          hdsize=$(getconf DISK_SIZE /dev/${hdpwr})
          (( hdsum += hdsize ))
          print -u3 "$hdpwr has size $hdsize"
     fi
done
print -u3 "Sum over all SYMMETRIX disks: $hdsum"
exec 3>&-

I hope this helps.

bakunin

1 Like

Hi,

Thank you I will give it a try on monday and let you know how it goes. Thanks for your help!

---------- Post updated 06-04-12 at 09:30 AM ---------- Previous update was 06-03-12 at 11:06 AM ----------

That worked amazing I edited it to make columns so i could put it straight onto a spread sheet

Thank you so much!!!