I am confused about a bash script.
I have the following code:
function grep_search() { magic_way_to_define_magic_variable_$1=`ls | tail -1` e
As per BashFAQ/006, you can use read with here string syntax for assigning indirect variables:
read
function grep_search() { read "$1" <<<$(ls | tail -1); }
Usage:
$ grep_search open_box $ echo $open_box stack-overflow.txt