sysctl with regex?
yanefbsd at gmail.com
Wed Feb 10 00:14:16 UTC 2010
On Feb 9, 2010, at 3:28 PM, Andrew Brampton wrote:
> 2010/2/9 Dag-Erling Smørgrav <des at des.no>:
>> Andrew Brampton <brampton+freebsd at 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.
>> You mean glob, not regexp...
> 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
>>> I could write:
>>> sysctl dev.cpu.*.temperature
>> Sounds like a good idea. Shouldn't be too hard to implement either.
> 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).
More information about the freebsd-hackers