Created
March 26, 2014 23:47
-
-
Save kojiromike/9796486 to your computer and use it in GitHub Desktop.
Someone's homework
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/!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