awk ...

If you have a server with a lot of file systems on it. Then this little “awk” command can come in useful. It can obviously be used in many other situations also.

In this example, the disk group name is /homedg/.

bash-3.00$ grep homedg /etc/vfstab
/dev/vx/dsk/homedg/sanlogs      /dev/vx/rdsk/homedg/sanlogs     /var/log/sanlogs vxfs    1       yes     -
/dev/vx/dsk/homedg/common      /dev/vx/rdsk/homedg/common     /usr/local/common vxfs    2       yes     -
bash-3.00$

bash-3.00$ awk '/homedg/{print "mount -F "$4,$1,$3}' /etc/vfstab
mount -F vxfs /dev/vx/dsk/homedg/sanlogs /var/log/sanlogs
mount -F vxfs /dev/vx/dsk/homedg/common /usr/local/common
bash-3.00$


If you run it with piping it to 'sh', then it will execute the command. You can replace the 'mount' with whatever command you like.

No comments: