配列にファイル名のリストをかなり簡単に入力してから、それを の引数として使用できます-a
。
while IFS= read -r attachment; do
attachments+=( "$attachment" )
done < listoffilestoattach.txt
for f in ../*.log; do
attachments+=("$f")
done
mutt -s "subject of message" -a "${attachments[@]}" -- myself@gmail.com < mail.txt
bash
4 以降を使用している場合は、while
ループを (少し) よりインタラクティブなreadarray
コマンドに置き換えることができます。
readarray -t attachments < listoffilestoattach.txt
場合のように、オプションmutt
ごとに 1 つのファイル-a
が必要な場合は、少し異なるものが必要になります。
while IFS= read -r attachment; do
attachments+=( -a "$attachment" )
done < listoffilestoattach.txt
for f in ../*.log; do
attachments+=( -a "$f")
done
mutt -s "subject of message" "${attachments[@]}" -- myself@gmail.com < mail.txt
を使用してreadarray
、試してください
readarray -t attachments < listoffilestoattach.txt
attachments+=( ../*.log )
for a in "${attachements[@]}"; do
attach_args+=(-a "$a")
done
mutt -s "subject of message" "${attach_args[@]}" -- myself@gmail.com < mail.txt