複数のリストがあり、リストに対していくつかのコマンドを実行したいと思います。リストが非常に長いので、コマンドを並列に実行したいので、nohup
各項目に対してnohupコマンドを含むループを
試しましたが、うまくecho
いきませcat another_list_of_names
ん./tools
。ループですが、'edはそれをstdoutに送ります。 nohupコマンドが並列に実行されるようにどのように設定しますか? (runを使用できますか?)cat
for a in $(cat list_of_names)
echo
for b in $(cat another_list_of_names)
nohup
echo
for a in $(cat list_of_names)
do
ID=`echo $a`
mkdir ${ID}
echo "
nohup sh -c '
for b in $(cat another_list_of_names)
do
./tools $b $a >> ${ID}/output
done' &
"
done
ベストアンサー1
あなたのコードをいくつか改善しました。
# This sort of loop is generally preferable to the one you had.
# This will handle spaces correctly.
while read a
do
# There's no need for the extra 'echo'
ID="$a"
# Quote variables that may contain spaces
mkdir "$ID"
# This is a matter of taste, but I generally find heredocs to be more
# readable than long echo commands
cat <<EOF
nohup sh -c '
while read b
do
# Quotation marks
./tools \$b $a >> "${ID}/output"
done < another_list_of_names' &
EOF
done < list_of_names