I'm simply trying to remove a % sign from a variable, so I may perform mathmatic calculations on the result. I've tried several things, but none of them seem to work:
$ output="23%"
# usep=$(echo $output | awk '{print $1}' | cut -d '%' -f 1)
# usep=`echo $output | sed 's/\%//g`
# usep=`echo $output | head -c 2`
The variable usep still contains the % character. Any ideas?
You may use POSIX parameter substitution:
$ output="23%"
$ usep=${output%%\%}
$ echo $usep
23
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With