Q: how check free space on particulat path

  • what is best command to check free space on particulat path
    previously i have used that way


    but after changes in dreambox mounting method this method returns wrong value

  • I would simply use grep to get rid of the unneeded lines and then the argument number for awk would be fixed again - something like this:


    df -h /media/hdd/movie/ | grep % | grep -v Files| awk {'print $3'}

  • @gutemine
    TANKS for reply, but still wrong value returned



    currently have fixed for self by create inside function in the script
    for storages which cant have 2TB and more

    Code
    CheckSpaceOnSrc () {
    	SrcInfo=`df $SrcDir| tail -1`
    	case "$DstInfo" in
    	/*) SrcFreeSpace=`echo $SrcInfo| awk {'print $4'}`;;
    	 *) SrcFreeSpace=`echo $SrcInfo| awk {'print $3'}`;;
    	esac
    }


    but for bigger storages same way just check before TB


    to able make all easier i miss some sed @&^#$ to remove first word only when it begins with /
    then awk {'print $3'} will work for any source


    full code of /usr/script/move_recordings_from_CF.sh

    • Offizieller Beitrag

    You can use python to calculate the free disk space yourself:


    Python
    #!/usr/bin/python
    from os import statvfs
    s = statvfs("/media/hdd")
    print s.f_bsize * s.f_bavail