Bash:コマンドの出力を一度に1行ずつ読み込む方法は?

Bash:コマンドの出力を一度に1行ずつ読み込む方法は?

.bashrcファイルを使用してbashからコマンド出力を読み取ろうとしますwhile loop

while read -r line
do
    echo "$line"
done <<< $(find . -type f)

私が得た結果

ranveer@ranveer:~/tmp$ bash test.sh
./test.py ./test1.py ./out1 ./test.sh ./out ./out2 ./hello
ranveer@ranveer:~/tmp$ 

その後私は試しました

$(find . -type f) | 
while read -r line
do
    echo "$line"
done 

しかし、エラーが発生しましたtest.sh: line 5: ./test.py: Permission denied

それでは、現在の行全体を一度に読むと思うので、1行ずつどのように読みますか?

希望の出力:

./test.py
./test1.py
./out1
./test.sh
./out
./out2
./hello

ベストアンサー1

バグがあります。< <(command)必要ありません。<<<$(command)

< <( )プロセスの交換$()はいコマンドの置き換えそして<<<ここにある文字列

おすすめ記事