kenv - output needed

Garrett Cooper yanefbsd at gmail.com
Wed Mar 24 02:47:54 UTC 2010


On Tue, Mar 23, 2010 at 6:42 PM, Andrew Thompson <thompsa at freebsd.org> wrote:
> On Wed, Mar 24, 2010 at 02:09:41PM +1300, Atom Smasher wrote:
>> On Tue, 23 Mar 2010, Garrett Cooper wrote:
>>
>>> Are you looking for data represented similar to sysctl(8)?
>> ============
>>
>> it doesn't quite have to be, but it is being parsed in a script.
>
> How about pulling the kenv variables into the script.
>
> #!/bin/sh
>
> eval $(kenv | awk -F= '/^smbios/ { gsub("\\\.","_",$1); print $1 "=" $2}')
>
> echo $smbios_chassis_maker

    That's assuming that the there are only two tokens separated by =
though... Maybe something like the following?

eval $(kenv | awk -F= '{ gsub("\\\.", "_", $1); x= ""; for (i=1; i <=
NF; i++) { if (i > 1) { x = x "="; } x = x "" $i; } print $1 "=" $x
}')

Thanks,
-Garrett


More information about the freebsd-hackers mailing list