[Chester LUG] Help with a bash script
Roger Gibson
rcgibson at talktalk.net
Mon Oct 18 21:12:18 UTC 2010
Takes me back to my Unix days, when I concocted all sorts of weird
things like this to automate the integrated processing of data coming
unreliably from a wide range of plant sensors, and feeding back to fine
tune the process. (If you have a reasonable recent reading use it, but
if not, ignore for now, or look back to a previous similar situation
....) Must come to meeting, but alas not next Thursday, unless quite
late, but I have a 6.00am flight out of Liverpool Friday morning. Roger.
On 18/10/2010 21:49, Stuart Burns wrote:
> 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
> <mailto: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 <mailto:Chester at mailman.lug.org.uk>
> > https://mailman.lug.org.uk/mailman/listinfo/chester
> >
>
> --
> Dr David Holden. (dh at iucr.org <mailto:dh at iucr.org>)
>
> _______________________________________________
> Chester mailing list
> Chester at mailman.lug.org.uk <mailto:Chester at mailman.lug.org.uk>
> https://mailman.lug.org.uk/mailman/listinfo/chester
>
>
>
> ______________________________________________________________________
> This email has been scanned by the MessageLabs Email Security System.
> For more information please visit http://www.messagelabs.com/email
> ______________________________________________________________________
>
>
> _______________________________________________
> 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/fe1f0fea/attachment.html>
More information about the Chester
mailing list