This is all you need to know:
~ $ top -bn1 |grep -A9999 "^ *PID " |awk '{foo+=$9} END {print foo}'
160.1
~ $ sensors |grep ^Package
Package id 0: +85.0°C (high = +100.0°C, crit = +100.0°C)
~ $ grep -m1 ^model.name /proc/cpuinfo
model name : 12th Gen Intel(R) Core(TM) i7-1260P
@RL_Dane
I have no idea what's going on. Yet, I know I could if I took the time to read the manpages and parse those flags.
I'm seriously conflicted right now.
Teaching mode, engage!
top -bn1 |grep -A9999 "^ *PID " |awk '{foo+=$9} END {print foo}'
top: Run 1 instance of top and send it to STDOUT instead of a fancy tty-aware screen
grep: show me at least 9,999 lines after anything that matches this regexp, and the match itself
awk: use foo as a variable to accumulate the values in field 9 (cpu usage), and print it out once EOF is reached
output: 160.1
...
@RL_Dane
Yikes, your use of awk is *far* more complex than mine.
Okay I think I've got this figured out so far.
I mean, awk is basically a complete programming language.
I've used it for two decades and still barely scratched the surface. ;)
@RL_Dane
~] man awk | wc -l
1660
~] calc "$(man awk | wc -l) - $(man tar | wc -l)"
651
That's not too bad. Perhaps I should take the time to figure it out.
What is `calc`? Where does that come from?
I've been using bc, just because that's what I know. It's not super elegant, but it works well:
$ echo "1+1" |bc
2
$ echo "5/2" |bc
2
$ echo "5/2" |bc -l
2.50000000000000000000
@RL_Dane
I don't remember why I didn't like bc, but there was a reason. I did try it.
Here's calc: https://github.com/lcn2/calc
I think I liked the interactive shell you get if you don't provide any arguments. Not sure.
Github pages are a total pain to browse with w3m.
Have you tried just using python as a math interpreter? ;)
@RL_Dane
You could just clone it and open the README in vim or less, you know.
And yes I have had python recommended to me and it works fine, but for whatever reason I abhor using python. I get shivers every time I consider it.
I guess I could use deno.
~] deno
Deno 1.31.1
exit using ctrl+d, ctrl+c, or close()
REPL is running with all permissions allowed.
To specify permissions, run `deno repl` with allow flags.
> 3 + 5
8
> 5 ** 30202
Infinity
> 0.1 + 0.2
0.30000000000000004
@RL_Dane
> [] + [0]
"0"
> [] * []
0
> [] / []
NaN
@RL_Dane
Don't you love JS?
Oh, that *was* JS.
I mean, JS has its own peculiarities like that, too.
@RL_Dane
That *is* JS. XD
@RL_Dane
*That's* how I feel about using python for basic math. ;)
I mean, I think it's a lot less odious than JS, but to each his own psychosis ;)
@RL_Dane
Oh I'd never use JS either. I'm just using it to illustrate the principle. XD
I wanted a dedicated utility, tried bc and didn't like it, tried calc and did.
@RL_Dane
Just for the record:
~] pytohn
pytohn: command not found
~] python
Python 3.10.9 (main, Dec 6 2022, 18:44:57) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 0.1 + 0.2
0.30000000000000004
DADGUM.
~ $ echo "0.1+0.2" |bc -l
.3
~ $ perl -e 'print 0.1+0.2,"\n"'
0.3
~ $ python -c 'print( 0.1+0.2 )'
0.30000000000000004
@RL_Dane
Let me introduce you to the most wonderful domain name ever: https://0.30000000000000004.com
Floating point math is tricky, ain't it? ;)
VERY cool. Both a great rant-as-URL, and very informative.