Skip to content

Instantly share code, notes, and snippets.

@kojiromike
Created March 26, 2014 23:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kojiromike/9796486 to your computer and use it in GitHub Desktop.
Save kojiromike/9796486 to your computer and use it in GitHub Desktop.
Someone's homework
#/!bin/bash
#
#Menunix - Bash
#
#Usage: menunixb
options=(
'List Files'
"Display today's date and time"
'Check whether a file is a directory or not'
'Create a file backup'
'Quit'
)
echo 'Please choose an option'
select input in "${options[@]}"; do
case "$input" in
"${options[0]}")
ls
;;
"${options[1]}")
date $'+Time: %T\nDate: %D'
;;
"${options[2]}")
read -p 'What file do you wish to check? ' finput
if [[ -d $finput ]]; then
format='%s is a directory.\n'
elif [[ -f $finput ]]; then
format='%s is a file.\n'
else
format='%s does not exist.\n'
fi
printf "$format" "$finput"
;;
"${options[3]}")
read -p 'Please enter filename to backup: ' binput
cp "$binput"{,.bak}
;;
"${options[4]}")
break
;;
*)
echo 'Not a valid option.'
;;
esac
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment