hankknight
asked on
Linux: Get rid of % when using grep and awk
I use this to trim the % from the end of a string:
I use this to return results from df in JSON format:
How can these two concepts be combined? I want to remove % from the JSON results.
x="10%"
echo ${x%\%}
I use this to return results from df in JSON format:
df |grep -iv "filesystem" | awk '{print"\""$1"\":"$5"," }'
How can these two concepts be combined? I want to remove % from the JSON results.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I think hankknight's "df" behaves like "df -P" (POSIX format, where the 5th column is "%Used").
df |grep -iv "filesystem" | awk '{print"\""$1"\":"$5"," }'
Can you post an example of what you see?