Dave, you must be a bash Jedi!<br><br>It does work, and I can kind of trace how it works, but would you mind explaining it a bit more ?<br><br>Cheers muchly. I owe you a beer, if your at the LUG next week ?<br><br><br><div class="gmail_quote">
On 18 October 2010 21:26, David Holden <span dir="ltr"><<a href="mailto:dh@iucr.org">dh@iucr.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hi Stuart,<br>
<br>
VERY quick hack but it may work, the grep allows # comments<br>
<br>
<br>
IFS=' ';<br>
<br>
datfile="1.dat"<br>
<br>
(<br>
cat $datfile | sort | grep -v \# | while read data<br>
do<br>
data_array=(`echo "$data"`)<br>
col1=${data_array[0]}<br>
echo -n "$col1 "<br>
cat $datfile | sort | grep "$col1" | awk '{print $2}' | tr '\n' ' '<br>
echo ""<br>
done<br>
) | sort | uniq<br>
<br>
<br>
Dave.<br>
<div><div></div><div class="h5"><br>
<br>
On 18/10/10 17:44, Stuart Burns wrote:<br>
> Hi everyone,<br>
><br>
> I am hoping someone can help me a bit here. I am creating a cript that<br>
> deals with volume groups. However my bash skills fall short.<br>
><br>
> I have a file that looks like this<br>
><br>
> Vg955-01 /dev/diska1<br>
> Vg955-01 /dev/diska2<br>
> Vg978-01 /dev/disk45<br>
> Vg978-04 /dev/disk13<br>
><br>
> You get the picture.<br>
><br>
> Now what I am trying to do is get all the vg parts followed by the<br>
> constituent disks. Ie above should look like:<br>
><br>
> Vg955-01 /dev/disk1a /dev/diska2<br>
> Vg978-01 /dev/disk45<br>
> Vg978-04 /dev/disk13<br>
><br>
> I cant really think of an easy way to do it without resorting to perl.<br>
> Can anyone help?<br>
><br>
> Regards<br>
><br>
> Stu<br>
><br>
</div></div>> _______________________________________________<br>
> Chester mailing list<br>
> <a href="mailto:Chester@mailman.lug.org.uk">Chester@mailman.lug.org.uk</a><br>
> <a href="https://mailman.lug.org.uk/mailman/listinfo/chester" target="_blank">https://mailman.lug.org.uk/mailman/listinfo/chester</a><br>
><br>
<font color="#888888"><br>
--<br>
Dr David Holden. (<a href="mailto:dh@iucr.org">dh@iucr.org</a>)<br>
<br>
_______________________________________________<br>
Chester mailing list<br>
<a href="mailto:Chester@mailman.lug.org.uk">Chester@mailman.lug.org.uk</a><br>
<a href="https://mailman.lug.org.uk/mailman/listinfo/chester" target="_blank">https://mailman.lug.org.uk/mailman/listinfo/chester</a><br>
</font></blockquote></div><br>