I’m using a case loop to allow me to either press 1 to accept the value in $fn3 ,press 2 to accept the value in $fn4 or press 3 to input my own value.
These are being used in a find statement. If I press 3 and enter a part of a file name, $search1 echoes the data I typed in correctly and all is ok. If I press either 1 or 2 the variable $search echoes the correct value of either $fn3 or $fn4 but when I assign search1 with *$search*, echo search1 now holds the list of files in my current folder and not the vale of $fn3 or $fn4.
The $search1 variable is being used in a find command later in the script. What's causing the files to appear in the variable?
case $ans in
1) search=$fn3;;
2) search=$fn4;;
3) read search;;
q*|Q*) quit 0;;
*) echo "please enter a number between 1 and 3";;
esac
echo $search #use to see what variable search holds
# $search hold part of the file name im going to search for,i add * for searching for anything which has the search vale in its name.
search1=*$search*
echo $search1 #use to see what variable search1