topical media & game development

talk show tell print

basic-shell-app-a-exercise-11-01.sh / sh



  # Assumes $1, first command-line argument,
  # names directory to list.
  
  directory=$1
  
  if [ ! -e directory ]
  then
      echo "Error: You must pass in the name of a directory."
      exit -1
  fi
  
  cd directory
  for filename in *
  do
      echo -n filename
  
      if [ -d filename ] 
      then
          echo "/"
      elif [ -x filename ] 
      then
          echo "*"
      else
          echo 
      fi
  done
  


(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.