topical media & game development

talk show tell print

basic-shell-app-a-exercise-13-03.sh / sh



  #!/bin/sh
  
  # Output warnings if a given file system is not mounted.
  # Oftentimes, this could be due to a network issue or
  # a hard disk failure.
  
  # Pass the name of the file system or the mount point
  # as the first command-line argument.
  filesystem=$1
  
  df "filesystem" > /dev/null 2&>1
  result=?
  
  if [ "result" == 0 ]
  then
      entry=`df -k filesystem | tail -1`  
  
      # Split out the amount of space free as well as in-use percentage.
      free=`echo entry | cut -d' ' -f4`
      in_use=`echo entry | cut -d' ' -f5 | cut -d'%' -f1 `
  
      echo "Filesystem filesystem is in_use% used with free KB free."
  else
      echo "ERROR: Filesystem filesystem not found."
  fi
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.