Operating System - Linux
1828104 Members
2321 Online
109974 Solutions
New Discussion

Re: remove a symbol from output

 
SOLVED
Go to solution
Jannik
Honored Contributor

remove a symbol from output

I have done it like this:
df -k /var | awk '/var/ {print $5}' | awk -F% '{print $1}'

Is there a better way?
jaton
5 REPLIES 5
Muthukumar_5
Honored Contributor

Re: remove a symbol from output

# bdf /var

hth.
Easy to suggest when don't know about the problem!
Muthukumar_5
Honored Contributor

Re: remove a symbol from output

You want to get only size using df -k then,

# df -k /var | awk ' NR==1 { print $5 }'

with bdf,

bdf /var | awk '!/Filesystem/ { print $2 }'

hth.
Easy to suggest when don't know about the problem!
Vibhor Kumar Agarwal
Esteemed Contributor

Re: remove a symbol from output

There are different ways:

I can give a combination of sed and awk

df -k /var | sed -e 's/\(.*\)%/g' | awk ' /var/ {print $5}'
Vibhor Kumar Agarwal
Vibhor Kumar Agarwal
Esteemed Contributor
Solution

Re: remove a symbol from output

Ooops missed a /

df -k /var | sed -e 's/\(.*\)%/\1/g' | awk ' /var/ {print $5}'
Vibhor Kumar Agarwal
Jannik
Honored Contributor

Re: remove a symbol from output

tnx
jaton