単一コマンドでファイル内の複数の値を順次実行
次のコマンドがあります
./test.sh -f test.txt
Completed Success
example.txtファイルの同じスクリプトに渡される入力は1000個あります。
スクリプトが実行されるたびに出力が成功します。
cat example.txt
test.txt
test1.txt
test2.txt
test3.txt
など
私はコマンドが各行を取得し、次のようにまとめて実行したいと思います。
./test.sh -f test.txt
Completed Success
./test.sh -f test1.txt
Completed Success
./test.sh -f test2.txt
Completed Success
など。
ベストアンサー1
使用for
またはwhile
繰り返し:
for i in `cat example.txt`; do ./test.sh -f $i;done
または
while read i; do ./test.sh -f $i;done < example.txt