I am getting error an error in a script:
#!/bin/bash
value='55'
size=`df -kh | grep '/vol/cdr/MCA' | awk '{print $5}'| sed 's/%//g'`
if [ "$size" -gt "$value" ] ;
then
delete=[ "$size" - "$value" ]
echo $delete
fi
Output:
[root@rohit ~]# sh -x test.sh
+ value=55
++ df -kh
++ grep /vol/cdr/MCA
++ awk '{print $5}'
++ sed s/%//g
+ size=78
+ '[' 78 -gt 55 ']'
+ delete='['
+ 78 - 55 ']'
test.sh: line 6: 78: command not found
+ echo
df
:size=$(df --output=pcent /vol/cdr/MCA | tail -n +2 | sed -e 's/ \|%//g')
. BTW, if you're usingawk
, you don't need to usegrep
, e.g.awk '/\/vol\/cdr\/MCA/ {print $5}'