1833783 Members
2203 Online
110063 Solutions
New Discussion

need help with scripting

 
SOLVED
Go to solution
hpuxhelp
Regular Advisor

need help with scripting

I need to remove 200 filesystems and each of these filesystems or some belongs to a different volume group...how would I do use awk to have it print out for me just 1 particulatr vg like vghello and everythings belong to that vg
10 REPLIES 10
Leif Halvarsson_2
Honored Contributor

Re: need help with scripting

Hi,
I am not exact sure what you want do do, to list all logical volumes belonging to one group, try:

ls /dev/vg00/lvol*
Steven E. Protter
Exalted Contributor

Re: need help with scripting

I would not use awk.

I would make a text file list of the following information:

/dev/vg00/lvname1
/dev/vg09/lvname2

call it input_file

while read -r xx
do
lvremove -f $xx
done < input_file


This script assumes the filesystem is already unmounted. If not, ask add second field space delimited. The second field will be the filesystem name.

Data is:
/dev/vg01/lvname1 /filesystemname

Script is:

while read -r xx yy
do
umount $yy
lvremove -f $xx
done < input_file


SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
John Poff
Honored Contributor

Re: need help with scripting

Hi,

If you just want to see all the filesystems that are belong to a single volume group, and if you are mounting them in /etc/fstab, you could just use 'grep' to see all those entries for a particular volume group.

Something like this might work:

grep vghello /etc/fstab

Of course, if you have vghello and vghello1 and vghello2, you might find all of them. But it is a start.

As Leif has mentioned, you can use the entries for the logical volumes in the volume group device directory to provide a list of logical volumes. You could feed that to another command like 'bdf' and grab the output.

I'm just curious, but why do you have to remove 200 filesystems?

JP
hpuxhelp
Regular Advisor

Re: need help with scripting

ok, i was able to extract all the elmenents out such mnt point , and have it as text,
how do I use that text file to umount all fileystems that i have in tthat text file..


bc we no longer needs these
Michael Steele_2
Honored Contributor

Re: need help with scripting

cat /dir/file | while read a b c d e f g h (* whatever, to end of line # of fields *)
do
fuser -ku $MOUNT_PT_VAR (*
umount $MOUNT_PT_VAR
lvremove $LOG_VOL_VAR
done
Support Fatherhood - Stop Family Law
hpuxhelp
Regular Advisor

Re: need help with scripting

ok...it is not working... hm..
i had a file name test
cat test
/hello
/hi
/work
/etc....

now, i want to umount all of these mnt point that currently in test..
how can i do that?

Michael Steele_2
Honored Contributor
Solution

Re: need help with scripting

cat test | while read a
do
fuser -ku $a
umount $a
done
Support Fatherhood - Stop Family Law
hpuxhelp
Regular Advisor

Re: need help with scripting

thank you mike...it works now...
hpuxhelp
Regular Advisor

Re: need help with scripting

one more question
if I hve something like this
hello#bye
and I want to remove # sign and add a space in between hello and bye ...

I tried the cut command but it is not working/
Tom Ward_1
Honored Contributor

Re: need help with scripting

couple of things

echo "hello#there" | sed 's/#/ /g'
gives "hello there"

and so does
echo "hello#there" | tr '#' ' '