[Info-vax] grep a nice one

David Mathog mathog at caltech.edu
Fri Jan 29 12:16:26 EST 2010


CY wrote:
> So, I will (after some playing around with DCL and search) dl the grep
> because I dont get this in a nice way in DCL:
> BIOS_VERSION=`dmidecode -t 0|grep Version|head -1| awk '{print $NF}'`

There was a VMS program written by Pat Rankin called EXTRACT which may 
still be around which I think might be able to handle this.  I missed it 
enough on linux/unix that I wrote a similar program, also called 
"extract" which can definitely do what you want, from one of our linux 
boxes:

% dmidecode -t 0 | extract -if Version -ifonly -mt -dl ' :' -cols '[2]'
080012

(Translation: match 'Version', only emit a line that matches, token 
mode, delimiter list is space colon, emit the second token.  There is 
only one "version" in the output of dmidecode, if there were more and 
you wanted only the first add : ' | extract -nr 1 ', which is the same 
as head -1. )

Never tested my extract on VMS though.  Probably it works since it's 
just a C program and isn't linked with any special libraries.  If you 
want to try it it is one of the programs in here:

http://saf.bio.caltech.edu/pub/software/linux_or_unix_tools/drm_tools.tar.gz

Regards,

David Mathog



More information about the Info-vax mailing list