4 ms·
Love this. Thanks. I can see a bunch of ways I'll make use of this. The first one I attempted to work on involved trying to color scale the use% in the output
by Fuzzwah 13y ago
Love this. Thanks.
I can see a bunch of ways I'll make use of this. The first one I attempted to work on involved trying to color scale the use% in the output of a "df -h".
Alas it didn't work as I expected it:
$ df -h | colout --scale 0,100 "([0-9]*)%" scale
ValueError: could not convert string to float:
However if I grep out just the /dev/sda line it does what I expected:
$ df -h | grep /dev/sda | colout --scale 0,100 "([0-9]*)%" scale
/dev/sda 20G 3.2G 16G 17% /
The 17% is a pretty blue.
Tips?
- Fuzzwah 13y agoAlso, the install docs mention python2.7 but after a bit of head to brickwall I realised that this is trying to use python3. To get it working I needed to do: sudo python3 setup.py install And /usr/local/bin/colout was created for me (unlike what it mentions in the readme atm).
- nojhan 13y agoYou use the "zero or more" * operator, which will match empty strings in front of the "%". But an empty string cannot be converted to a float. Just use the "at least one" operator: +. Also, the scale is 0,100 by default, you can omit it. df -h | colout "([0-9]+)%" scale
- Fuzzwah 13y agoThanks for the response. My lazy regex makes me feel bad.