I want to use for for a set of files.
for file in fileA fileB fileC; do
COMMAND $file $variable
done
For every $file I want to use specific $variable.
(for example: fileA variableA; fileB variableB)
How can do such association?
Since you are on v4 of bash, associative arrays are an option
declare -A arr
arr=([fileA]=variableA [fileB]=variableB [fileC]=variableC)
for file in "${!arr[@]}"
do
command "$file" "${arr[$(basename $file)]}"
done
Note that order of processing may be different from the order within the array definition
declare -A filevars
filevars[fileA]=foo
filevars[fileB]=bar
filevars[fileC]=baz
for file in fileA fileB fileC; do
echo cmd "$file" "${filevars[$file]}"
done
varA1 varA2 for fileA, etc?
bash?if [$ID="fileA"]results incommand not foundhere...