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. if status case statement, but some failure .. .. Well, my question is:
when I 2 , then the user paths to the first file and if there is any other way then i will look in the default path as i mentioned Or should to search, but I could not get here this function, anyone concerned can help me? I would be grateful for your help :)

My code is:

  #! / 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

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -