Hope you are doing well. I am kind of new to bash scripting so I wanted to ask you a question on something I stumbled upon just recently when I was playing around with the find command. What I had noticed was that when I search for a script name using the find command using the command substitution in the bash script, and call the variable from command substitution, it will find the script full path and also execute it right after. Can you please let me know why and how this is working? E.g.
SEARCH=$(find / -type f -iname "script.name" 2> /dev/null)
$SEARCH
Regards
findprints the full path of the script and assigns it toSEARCH. The line$SEARCHexecutes the script.$SEARCHexpands to/path/to/script, then writing$SEARCHis (basically) the same as writing/path/to/script.bashparses the line and attempts to execute it.