[Chester LUG] Help with a bash script

Stuart Burns stuart.james.burns at gmail.com
Mon Oct 18 20:49:40 UTC 2010


Dave, you must be a bash Jedi!

It does work, and I can kind of trace how it works, but would you mind
explaining it a bit more ?

Cheers muchly. I owe you a beer, if your at the LUG next week ?


On 18 October 2010 21:26, David Holden <dh at iucr.org> wrote:

> 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)
>
> _______________________________________________
> Chester mailing list
> Chester at mailman.lug.org.uk
> https://mailman.lug.org.uk/mailman/listinfo/chester
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.lug.org.uk/pipermail/chester/attachments/20101018/abae241b/attachment.html>


More information about the Chester mailing list