Created
April 26, 2016 05:09
-
-
Save vunhan/7095967b586c4f27ccc3a2a0f68932d6 to your computer and use it in GitHub Desktop.
not done yet
This file contains hidden or 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
# ---------------------------------- | |
# Step #2: User defined function | |
# ---------------------------------- | |
pause(){ | |
read -p "Press [Enter] key to continue..." fackEnterKey | |
} | |
# Looking in path? | |
path(){ | |
echo "Looking in path: " | |
read find_path | |
echo $find_path | |
pause | |
} | |
# Extensions? | |
extension(){ | |
echo "Extensions?" | |
read find_extensions | |
pause | |
} | |
# File size | |
size(){ | |
echo "size" | |
read find_size | |
pause | |
} | |
# Output? | |
output(){ | |
echo "Output" | |
read find_output | |
pause | |
} | |
# Execute find command | |
my_find(){ | |
echo $find_size | |
find $find_path -name "*.$find_extensions" -size -$find_sizek > $find_output | |
pause | |
} | |
# function to display menus | |
show_menus() { | |
clear | |
echo "~~~~~~~~~~~~~~~~~~~~~" | |
echo " M A I N - M E N U" | |
echo "~~~~~~~~~~~~~~~~~~~~~" | |
echo "1. Path" | |
echo "2. File extensions" | |
echo "3. Size" | |
echo "4. Output location" | |
echo "5. Find & save log" | |
echo "6. Exit" | |
} | |
# read input from the keyboard and take a action | |
# invoke the one() when the user select 1 from the menu option. | |
# invoke the two() when the user select 2 from the menu option. | |
# Exit when user the user select 3 form the menu option. | |
read_options(){ | |
local choice | |
read -p "Enter choice [ 1 - 6] " choice | |
case $choice in | |
1) path ;; | |
2) extension ;; | |
3) size ;; | |
4) output ;; | |
5) my_find ;; | |
6) exit 0;; | |
*) echo -e "${RED}Error...${STD}" && sleep 2 | |
esac | |
} | |
# ---------------------------------------------- | |
# Step #3: Trap CTRL+C, CTRL+Z and quit singles | |
# ---------------------------------------------- | |
trap '' SIGINT SIGQUIT SIGTSTP | |
# ----------------------------------- | |
# Step #4: Main logic - infinite loop | |
# ------------------------------------ | |
while true | |
do | |
show_menus | |
read_options | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment