Мне нужна помощь с getopts
.
Я создал Bash script, который выглядит следующим образом:
$foo.sh -i env -d каталог -s подкаталог -f файл
Он корректно работает при обработке одного аргумента из каждого флага. Но когда я вызываю несколько аргументов из каждого флага, я не уверен, как вывести информацию из нескольких переменных из переменных в getopts
.
while getopts ":i:d:s:f:" opt
do
case $opt in
i ) initial=$OPTARG;;
d ) dir=$OPTARG;;
s ) sub=$OPTARG;;
f ) files=$OPTARG;;
esac
done
После захвата параметров я хочу построить структуры каталогов из переменных
foo.sh -i test -d directory -s subdirectory -s subdirectory2 -f file1 file2 file3
Тогда структура каталогов будет
/test/directory/subdirectory/file1
/test/directory/subdirectory/file2
/test/directory/subdirectory/file3
/test/directory/subdirectory2/file1
/test/directory/subdirectory2/file2
/test/directory/subdirectory2/file3
Любые идеи?