Hi Experts
I need an script to add an disk in to the veritas volume manager disk group.
For example:
# cd /tmp
# view disk
c6t5d2
c6t2d1
c6t3d7
c6t11d2
c7t11d2
c6t11d6
Normally we add the disk like this:
# vxdg -g freedg freedisk01=c6t5d2
# vxdg -g freedg freedisk02=c6t2d1
# vxdg -g freedg freedisk03=c6t3d7 and so on..
I am looking for for forloop where i could use freedisk(n+1) till all the disk get added.
# for i in `cat /tmp/disk`
do
vxdg -g freedg freedisk(n+1)=$i
done
I am not sure about the correct syntax used in above script for freedisk(n+1) appreciate if any one could suggest me.
Regards
Indrajit Bhagat
Hi
$ awk '{printf "vxdg -g freedg freedisk%02d=%s\n",++i,$0;}' /tmp/disk
vxdg -g freedg freedisk01=c6t5d2
vxdg -g freedg freedisk02=c6t2d1
vxdg -g freedg freedisk03=c6t3d7
vxdg -g freedg freedisk04=c6t11d2
vxdg -g freedg freedisk05=c7t11d2
vxdg -g freedg freedisk06=c6t11d6
If this is the output you expected, you can redirect the above output to a file and run it.
Guru.
In ksh you could also use:
#!/bin/ksh
typeset -Z2 n=1
for i in $(cat /tmp/disk)
do
vxdg -g freedg freedisk$n=$i
((n++))
done
#!/bin/sh
disknum=14
for i in `cat /tmp/disk`
do
if [ $disknum -lt 18 ]; then
vxdg -g freedg adddisk disk$disknum=$i
else
echo "All the disk is added to the diskgroup"
fi
disknum=$(( disknum +1 ))
done
Which is working fine now