#! /bin/bash # # files - demonstrates some bash features related to files. # Call this script with one argument, a name of a file. # # (try it with a few differnt files including directories and files # you don't own) # if [ -d $1 ]; then echo "file exists and is a directory" fi if [ -e $1 ]; then echo "file exists" fi if [ -f $1 ]; then echo "file exists and is a regular file (not a directory or other special type of file" fi if [ -r $1 ]; then echo "you have read permission on the file" fi if [ -w $1 ]; then echo "you have write permission on the file" fi if [ -x $1 ]; then echo "you have execute permission on the file" fi if [ -O $1 ]; then echo "you own the file" fi if [ -G $1 ]; then echo "the files group ID matches yours" fi