Предполагая, что ваш файл содержит по одному файлу на строку, вы можете сделать такую уродливую вещь:
tool="cgatools join --beta --match <specification> --overlap <overlap_spec> --select <output_fields> --always-dump --output-mode compact --input"
{
read -r filename
cmd="cat \"$filename\""
while read -r filename; do
cmd+=" | $tool \"$filename\""
done
} < file_of_filenames
cmd+=" > output_file"
echo "$cmd"
eval "$cmd"
В документации сказано, что если задан только один входной файл, другой файл читается из стандартного ввода, и если параметр --output не указан будет использоваться стандартный вывод.
непроверено, но это тоже может сработать (bash)
# declare the cgatools command with options
# stored in a shell array.
cga_join=(
cgatools join --beta
--match "specification"
--overlap "overlap_spec"
--select "output_fields"
--always-dump
--output-mode compact
)
# the entry point to the join process
# shift the first argument off the list of arguments, and
# pipe its contents into the recursive call
call_join() {
local first=$1
shift
cat "$first" | call_join_recursively "$@"
}
# recursively call "cgatools join"
# input will be read from stdin; output goes to stdout
# if this is the last filename to join, pipe the output through "cat"
# otherwise pipe it into another call to this function, passing the
# remaining filenames to join.
call_join_recursively() {
local file=$1
shift
local next_command=(cat)
if [[ $# -gt 0 ]]; then
next_command=( "$FUNCNAME" "$@" )
fi
"${cga_join[@]}" --input "$file" | "${next_command[@]}"
}
# read the list of filenames to join.
# stored in the "filenames" array
mapfile -t filenames < file_of_filenames
# launch the joining, passing the filenames as individual arguments.
# store the output into a file.
call_join "${filenames[@]}" > output_file