#!/bin/bash # playing with if statements # # by: Sharon Tuttle # last modified: 2022-09-12 # if no command-line argument is given, ask for user input if [ $# -eq 0 ] then echo -n "Enter a file name: " read input else input=$1 fi echo "\$input: [$input]" # if first command line argument or what was entered # is not a file name, complain and exit if [ ! -e $input ] then echo "$0: $input does not exist" echo "...exiting" exit 1 fi # if reach here, should be reasonable to display # permissions of first command line argument # or what was entered, as it is a file name # that exists echo "$input's permissions: " ls -l $input