3 ms·
In some cases the sysctl output is not easily machine-parseable. For example, the uptime information from sysctl -n kern.boottime This largely misses the poin
by inferiorhuman 7y ago
In some cases the sysctl output is not easily machine-parseable. For example, the uptime information from sysctl -n kern.boottime
This largely misses the point. The output of sysctl(8) is not intended to be machine readable. Instead of parsing strings you should be using sysctl(3) directly or through whatever bindings for your language of choice.
- toast0 7y agoI don't believe POSIX shell or awk have bindings for sysctl(3)?
- inferiorhuman 7y agoI don't believe POSIX shell or awk have bindings for sysctl(3)? That's essentially what sysctl(8) is. Unlike Linux though the text interface isn't really intended to be the primary API. The article discusses using Rust and C which both have access to sysctl(3).
- Arnavion 7y agoYes, now that I realize `sysctl -b` exists, I've retracted that part of the blog post.