bash未在while循环中列出文件
下面的bash未在while循环中列出文件,bash,sed,Bash,Sed,下面的bash似乎正在运行,但终端屏幕上没有显示文件名,而只是暂停。我似乎不明白为什么它现在不像以前那样工作了。谢谢:) bash while read line; do sed -i -e 's|https://www\.example\.com/xx/x/xxx/||' /home/file echo $line done 文件 Auto_user_xxx-39-160506_file_name_x-x_custom_xx_91-1.pdf Auto_user_xxx-48-160601
bash
似乎正在运行,但终端屏幕上没有显示文件名,而只是暂停。我似乎不明白为什么它现在不像以前那样工作了。谢谢:)
bash
while read line; do
sed -i -e 's|https://www\.example\.com/xx/x/xxx/||' /home/file
echo $line
done
文件
Auto_user_xxx-39-160506_file_name_x-x_custom_xx_91-1.pdf
Auto_user_xxx-48-160601_V4-2_file_name_x-x_custom_xx_101.pdf
coverageAnalysisReport(10).zip
read
命令正在等待输入,因为没有指定任何内容,它将从stdin读取。如果您键入几行并按下,您将看到这是循环的输入
但您很可能希望将文件重定向到循环:
while IFS= read -r line; do
printf "%s\n" "$line"
done < /home/file
read
命令正在等待输入,因为没有指定任何内容,它将从stdin读取。如果您键入几行并按下,您将看到这是循环的输入
但您很可能希望将文件重定向到循环:
while IFS= read -r line; do
printf "%s\n" "$line"
done < /home/file
它试图从stdin读取,因为您没有重定向任何内容,它将等待您键入。它试图从stdin读取,因为您没有重定向任何内容,它将等待您键入。