0
#! /usr/bin/bash
clear
df -h | awk 'NR==1'
df -h | awk 'NR==3'
echo
Msize=30 
DS=$(df -h / | grep / | awk '{print $4}' | sed 's/%//g')
echo $DS
echo 
space=70 
Fsize= du -ch /home/sawan/Desktop
if [[ $DS -ge $spcae ]]
then  
    echo "Size available $DS"
    if [[ $fsize -le $Msize ]]
    then
    echo "Ingestion successfull"
    else
    echo "Ingestion Unsuccessfull"
    fi
else             
echo "Disk Space not available"`
fi 

Outpu

if i am removing the -h the code is running properly but giving value in KB. i want the value in GB

James Z
  • 12,209
  • 10
  • 24
  • 44
  • 2
    Then get it in KB and divide by a million (or 1,048,576). `72G` is not recognised as a number by any shell. – rici Sep 30 '22 at 14:40
  • 1
    How is `-ge` supposed to compare, say, `1G` and `512M`; or `72G` and `1T`? If it just ignores the letters it'll say 512 is bigger. It's _numeric_ comparison; it doesn't know about unit suffixes, so it's right and proper that it throws up its hands and refuses to parse something as a number that _isn't_ a number. – Charles Duffy Sep 30 '22 at 15:25

0 Answers0