I have a shell script as the following, where I want to call another of my already existing shell script, and execute it as it would normally do. for example, if someone commands "s" from the following menu, I want this script to search all my directories for the file "isearch" and execute it on the terminal, so that they can work on isearch. What is the exact code to search and execute the existing file.

I have tried this, but this does not work-

find / -type f -iname "isearch" -exec {} \

The following works for the script to run in my computer, but how can I make it run for anyone who has all those files too but may be in different folders.


Here is the script with a menu from which the other scripts will be called.

    echo "==============  MENU  =============="
    echo "s: Search for a word"
    echo "c: Count lines, words, characters"
    echo "r: Clear the screen"
    echo "q: Quit the program"
    echo "===================================="
    echo " "
    echo -n "Enter command: " 
    read usercommand

Thanks in advance.

1 Answer 1


Try keeping the code within the same program and jumping to it with a function and case such as below ...

echo -n "Enter command: " 
read userCommand
case "$userCommand" in
[Ss] )
    echo ''

function searchWord {
    #Enter code here

However if you really want to run separate files then another command you could look into is using 'grep' and taking the output from that in the script.

If you store a magic value within the header of the file and then use the command

x="$(find | grep -rl "MagicValue")"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .