I'm new with shell programming. My goal is to give the user a selection which file should be run. I catch all available scripts in one var with:
var=$(find script*)
so far so good, this is the output:
echo $var
script1 script2 script3 scr...
now I want to store each file in a singel variable to run it in later selection
select SEL in script1 script2 script3 ..........
case $SEL in
$Script1) echo ($Script1 will start) && ./$script1 ;;
$Script2) echo ($Script2 will start) && ./$script2 ;;
$Script3) echo ($Script3 will start) && ./$script3 ;;
$Sc..) echo ($Scr.... will start) && ./$scrip.... ;;
$Sc...) echo ($Sc...... will start) && ./$scrip..... ;;
*) echo "choose on of the availabel files";;
esac
done
I don't have a clue how should I should separate all files if I don't know how many and the exactly length of each file.
I tried to split with echo ${var[1]} and echo $var[1] but this dosn't work. I recive either a empty output or the whole string.
find script*
doesn't make sense: it lists files matchingscript*
in the current directory, and if any of these is a subdirectory, its contents is listed recursively. Did you mean to use files matchingscript*
directly in the current directory? Or files with matching names in the current directory or its subdirectories and so on recursively?