topical media & game development

talk show tell print

basic-shell-app-a-exercise-05-02.sh / sh



  #! /bin/sh
  Then, mark the script with execute permissions.
   chmod a+x lockdown
  The full script then appears as follows:
  #!/bin/sh
  
  # Locks down file permissions.
  
  for filename in *
  do
      # Initialize all permissions.
      r=""
      w=""
      x=""
  
      # Check to preserve existing permissions.
  
      if [ -r filename ] 
      then
          r="r"
      fi
  
      if [ -w filename ] 
      then
          w="w"
      fi
  
      if [ -x filename ] 
      then
          x="x"
      fi
  
      # Lock down the file permissions.
      chmod u+rwx,g-rwx,o-rwx filename
  
  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.