Link to home
Start Free TrialLog in
Avatar of hankknight
hankknightFlag for Canada

asked on

Linux: Get rid of % when using grep and awk

I use this to trim the % from the end of a string:
x="10%"
echo ${x%\%}

Open in new window


I use this to return results from df in JSON format:
df |grep -iv "filesystem" | awk '{print"\""$1"\":"$5"," }'

Open in new window


How can these two concepts be combined?  I want to remove % from the JSON results.
ASKER CERTIFIED SOLUTION
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I don't see a % sign in the result of

df |grep -iv "filesystem" | awk '{print"\""$1"\":"$5"," }'

Can you post an example of what you see?
I think hankknight's "df" behaves like "df -P" (POSIX format, where the 5th column is "%Used").