Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
bash未在while循环中列出文件_Bash_Sed - Fatal编程技术网

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读取,因为您没有重定向任何内容,它将等待您键入。