[Chester LUG] Help with a bash script
David Holden
dh at iucr.org
Mon Oct 18 20:26:12 UTC 2010
Hi Stuart,
VERY quick hack but it may work, the grep allows # comments
IFS=' ';
datfile="1.dat"
(
cat $datfile | sort | grep -v \# | while read data
do
data_array=(`echo "$data"`)
col1=${data_array[0]}
echo -n "$col1 "
cat $datfile | sort | grep "$col1" | awk '{print $2}' | tr '\n' ' '
echo ""
done
) | sort | uniq
Dave.
On 18/10/10 17:44, Stuart Burns wrote:
> Hi everyone,
>
> I am hoping someone can help me a bit here. I am creating a cript that
> deals with volume groups. However my bash skills fall short.
>
> I have a file that looks like this
>
> Vg955-01 /dev/diska1
> Vg955-01 /dev/diska2
> Vg978-01 /dev/disk45
> Vg978-04 /dev/disk13
>
> You get the picture.
>
> Now what I am trying to do is get all the vg parts followed by the
> constituent disks. Ie above should look like:
>
> Vg955-01 /dev/disk1a /dev/diska2
> Vg978-01 /dev/disk45
> Vg978-04 /dev/disk13
>
> I cant really think of an easy way to do it without resorting to perl.
> Can anyone help?
>
> Regards
>
> Stu
>
> _______________________________________________
> Chester mailing list
> Chester at mailman.lug.org.uk
> https://mailman.lug.org.uk/mailman/listinfo/chester
>
--
Dr David Holden. (dh at iucr.org)
More information about the Chester
mailing list