Everything is in the title.Example :VARIABLE1=/foo/barVARIABLE2=/some/other/path# etc you don't know how many variables there is, maybe 3 maybe 30.# Then :randomfunction $VARIABLE1 $VARIABLE2 #... <- How do I replace this to something that would include every variable starting with name VARIABLEEDITAs there is some misunderstanding, let me put it differently : How do I make :VAR1=fooVAR2=barVAR3=jobbeing outputed as : foo bar job without knowing the number of VAR, maybe there is also VAR4, maybe VAR5 etc.
How to pass as much arguments to a function as there is variables starting with string?
bash;shell script;shell
If you run the set command without any arguments, it will output all the variables and functions that where set for the session, with that in mind is just a matter of filtering the variables and then filtering the string you want from those variables, assign that to an array and then pass the array to the function.ALL_VARIABLES=( $(set | grep -Ea '^VARIABLE.*=' | cut -d = -f 2) )randomfunction ${ALL_VARIABLES[@]}basically you will get all the output from set and grep for any line that starts with VARIABLE followed by any characters and an equal sign, then you will pass it to cut to separate name and value, and assign all the values to the ALL_VARIABLES array, which then will be expanded and passed as arguments to randomfunction