xargs в сочетании с bash -c с несколькими заполнителями

Без причудливых монтирований gvfs или sshfs вам нужно использовать sftp-клиент. Я выбираю lftp>=4.7, потому что он работает с каналами FIFO (scp, а sftp— нет ).

Работает с bashв Linux:

tar --exclude='./somefolder' -zc. \
 | tee >(lftp -c 'connect sftp://user:pass@server/path/ ;put /dev/stdin -o sth.tar.gz;') \
 | sha256sum

В качестве альтернативы можно использовать sshклиент (внешние скобки, необходимые для интерактивной аутентификации по паролю):

(tar --exclude='./somefolder' -zc. \
 | tee >(ssh user@server "cat > /path/sth.tar.gz") \
 | sha256sum)

Заметьте, tee'sаргумент тоже выглядит немного экзотично, но это не -переносимая bashмагия, позволяющая избежать дополнительных mkfifoкоманд, объясненных вman bash:

Process Substitution

Process substitution is supported on systems that support named pipes (FIFOs) or the /dev/fd method of naming open files. It takes the form of <(list) or >(list). The process list is run with its input or output connected to a FIFO or some file in /dev/fd. The name of this file is passed as an argument to the current command as the result of the expansion. If the >(list) form is used, writing to the file will provide input for list. If the <(list) form is used, the file passed as an argument should be read to obtain the output of list.

2
23.09.2019, 15:38
2 ответа
  1. Не анализировать

  2. xargsне поддерживает два заполнителя.

  3. Используйте цикл for. На самом деле, два цикла (один для имен файлов и один для последовательности 12..14 ).

    Например:

#!/bin/bash

for f in barcode0[1-4].fastq; do
  bn="$(basename "$f".fastq)"
  for k in {12..14}; do
    krocus --verbose --output_file "out_krocus/${bn}_${k}Ecoli1.txt" \
      /nexusb/Gridion/MLST_krocus_DBs/e_coli1 --kmer "$k" "$f"
  done
done
5
27.01.2020, 21:58

При использовании GNU Parallel это выглядит так:

parallel krocus --verbose --output_file out_krocus/{1.}_{2}Ecoli1.txt /nexusb/Gridion/MLST_krocus_DBs/e_coli1 --kmer {2} {1} ::: barcode0[1-4].fastq ::: {12..14}
0
27.01.2020, 21:58

Теги

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