ОШИБКА :не удалось вставить «slram»

Использование параллелизма GNU в скрипте:

#!/bin/bash

constant=constant

populate_file () {
    local const=$1
    local file=$(basename -s '.M0.ctl' "$2")
    printf '%s\n%s\n%s\n' \
    "seqfile = ${file}_p.phy" \
    "treefile = ${const}.txt" \
    "outfile = ${file}_M0_mlc" > "$2"
}

export -f populate_file

parallel populate_file "$constant" {}.M0.ctl :::: list.txt

Это будет читать строки из list.txtи выполнять функцию populate_fileдля каждой из них параллельно. Функция populate_fileвыводит три строки в нужном формате в каждый файл.

При отсутствии параллелизма GNU вы можете использовать цикл чтения while:

#!/bin/bash

constant=constant

populate_file () {
    local const=$1
    local file=$(basename -s '.M0.ctl' "$2")
    printf '%s\n%s\n%s\n' \
    "seqfile = ${file}_p.phy" \
    "treefile = ${const}.txt" \
    "outfile = ${file}_M0_mlc" > "$2"
}

while IFS= read -r file; do
    populate_file "$constant" "${file/ /}.M0.ctl"
done < list.txt
0
31.05.2020, 13:17
0 ответов

Теги

Похожие вопросы