On Wed, 16 Dec 2009, Rogan Creswick wrote:

> It also doesn't *really* matter that they are, though.  If you should try
> to run a pdf as a script, you'll just get some error, or nothing at all.
> (shell vs. a double-click in some file browser.

   Here's a script John can use to explore his home directory (as well as
others). It is from chapter 5 of the ORA book on the bash shell. I call it
'showme.sh'. RUn it by making it executable ('chmod a+x') and specifying all
files in the directory. For example, ./showme.sh *

------------------------------------------------------------------------
#!/bin/bash

finfo ()
{
     if [ ! -e "$1" ]; then
         print "file $1 does not exist."
         exit 1
     fi
     if [ -d "$1" ]; then
         echo -n "$1 is a directory that you may "
         if [ ! -x "$1" ]; then
             echo -n-n "not "
         fi
         echo "search."
     elif [ -f "$1" ]; then
         echo "$1 is a regular file."
     else
         echo "$1 is a special type of file."
     fi
     if [ -O "$1" ]; then
         echo 'You own the file.'
     else
         echo 'You do not own the file.'
     fi
     if [ -r "$1" ]; then
         echo 'You have read permissions on the file.'
     fi
     if [ -w "$1" ]; then
         echo 'You have write permissions on the file.'
     fi
     if [ -x "$1" ]; then
         echo 'You have execute permissions on this file.'
     fi
}

for filename in "$@" ; do
     finfo "$filename"
     echo
done
--------------------------------------------------------------

   Two lessons in one: permissions and shell scripting.

Rich
_______________________________________________
PLUG mailing list
[email protected]
http://lists.pdxlinux.org/mailman/listinfo/plug

Reply via email to