bash - Shell Script to display menu -
I have a problem with my shell script, I have written a very small example but I can not find the expected output. My code is: if
status
when I 2
#! / Bin / bash trap '' 2 reality clear eco-e "T. ******************************** ************************************************** ************************************ "echo -e" \ t ********* ********** Test-Menu ** ****************************************************************************** ************************************************************************************************ ************************************************************************************************** "Echo -e" \ t \ t 1) Show date / time "echo -e" \ t \ t 2) file search "echo-e" \ t \ te) end \ n "echo-e" \ t \ t Select your choice: \ c "; Answer read echo -e "\ t ****************************************** ************************* "1) date + case $ answer '% y% m% d% H:% M:% S' ;; 2) echo -e "Please rate it: \ c"; ["$ Directory" = ""] Then $ directory = "[/ test / sample /]" echo -e "enter your file [$ directory]: \ c"; Search "$ directory" -name "* $ search *" Search-type f -print | Xargs ls -l ;; E) exit ;; Esac echo -e "Enter the return to continue \ c" read the answer
Couple issues:
-
variable assignment
$ directory = "[/ test / sample /]"
If you do not use the $ when you are specifying the value, then you should use it as
directory = "[/ test / sample /]" fi-
Your default directory
$ directory = "[/ test / sample /]" fi
Why you need square brackets Will it be? Are you doing LS [/ test / sample]? Just remove it. The
-
If you
If [ "$ directory" = ""]
If users sign in now if it is to work If you are not going to go, then you should do this:
If ["x $ directory" = "x"]
-
You can add LS And can look like:
"$ directory" -name " $ search " -type f -exec ls -l {} \;
Comments
Post a Comment