Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 9 Feb 2010 16:14:12 -0800
From:      Garrett Cooper <yanefbsd@gmail.com>
To:        Andrew Brampton <brampton+freebsd@gmail.com>
Cc:        =?iso-8859-1?Q?Dag-Erling_Sm=F8rgrav?= <des@des.no>, freebsd-hackers@freebsd.org
Subject:   Re: sysctl with regex?
Message-ID:  <26049703-8844-4476-B277-776A4EFC0A53@gmail.com>
In-Reply-To: <d41814901002091528i4884987cmb7347dfe4d50bdc5@mail.gmail.com>
References:  <d41814901002091308s7e894b55p880bde165bbbe703@mail.gmail.com> <86tytqvwky.fsf@ds4.des.no> <d41814901002091528i4884987cmb7347dfe4d50bdc5@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Feb 9, 2010, at 3:28 PM, Andrew Brampton wrote:

> 2010/2/9 Dag-Erling Sm=F8rgrav <des@des.no>:
>> Andrew Brampton <brampton+freebsd@gmail.com> writes:
>>> Today I was writing a script to read all the dev.cpu.?.temperature
>>> sysctl OIDs. I was parsing them using a simple grep, but it occurred
>>> to me it might be better if sysctl supported some form of regexp.
>>=20
>> You mean glob, not regexp...
>=20
> Could you explain why do I mean glob instead or regexp?
> Is glob simple matches, ie * and ?
> and regexp more complex like [a-z]*

C-shell globs as some programming languages referring to it as, i.e. =
perl (which this is a subset of the globs concept) allow for expansion =
via `*' to be `anything'. Regexp style globs for what you're looking for =
would be either .* (greedy) or .+ (non-greedy), with it being most =
likely the latter case.

>>> For example instead of typing:
>>> sysctl -a | grep dev.cpu.*.temperature
>>>=20
>>> I could write:
>>> sysctl dev.cpu.*.temperature
>>=20
>> Sounds like a good idea.  Shouldn't be too hard to implement either.
>=20
> If I get time I might submit a patch.

	I'll see if I can whip up a quick patch in the next day or so -- =
but before I do that, does it make more sense to do globs or regular =
expressions? There are pluses and minuses to each version and would =
require some degree of parsing (and potentially escaping).
Thanks,
-Garrett=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?26049703-8844-4476-B277-776A4EFC0A53>