Artificial intelligent assistant

"awk with if / substr " didn't work as expected I want to filter the records where disk usage is greater than 70% using df and awk/if/substr. The problem is it looks like only the first character is considered when comparing: **commands:** # df -Pah | awk '{if(substr($5,1,length($5)-1)>70) print $5}' Use% 9% 8% But like this it works: **commands:** # df -Pah | awk '{if(substr($5,1,length($5)-1)-70>0) print $5}' 100% 100% 100% # df -Pah | awk '{if(substr($5,1,length($5)-1)-30>0) print $5}' 54% 35% 100% 100% 100% Does anyone know why? PS: `df -Pah` output, in fact it's quit the same as `df -h`: Filesystem Size Used Avail Use% Mounted on /dev/sda2 2.0G 1020M 894M 54% / udev 4.0G 420K 4.0G 1% /dev tmpfs 4.0G 16M 3.9G 1% /dev/shm

Awk comparisons are as I recall either numeric or string comparisons, depending on the type of the left operand, and that would explain what you're seeing: `substr` gives a string result, and strings beginning 'U', '9', and '8' are all greater than any string beginning '7'.

Subtraction produces a numeric result.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 9b20b5b92e9130cbe06599a15735da86