我正在运行一直正常工作的脚本。但是,昨天,我遇到了一些错误。 这些错误后脚本的几个循环:Grep没有这样的文件或目录错误在Bash脚本中,我应该插入等待命令吗?
sed: cant read file3.txt: No such file or directory
grep: file3.txt: No such file or directory
grep: file3.txt: No such file or directory
sed: cant read file3.txt: No such file or directory
grep: file3.txt: No such file or directory
请记住,这些错误不会发生一致。它在脚本的这部分附近发生了一段时间。 File3.txt是未找到该文件:
cat file1.txt | while read LINE; do grep -m 1 $LINE file2.txt >> file3.txt; done
sed -i 's/string//g' file3.txt
grep 'string' file3.txt | cut -d '|' -f1-2 > file4.txt
grep -v 'string' file3.txt | cut -d '|' -f1-2 >> file5.txt
sed -i 's/string//' file3.txt
grep -Fvf file3.txt file1.txt > file6.txt
现在,我在想,既然file3.txt是附加的,或以后通过SED操作上,有时下一个命令太早开始,它无法找到该文件?我应该在两者之间放置一个等待命令吗?
我已经看过了这个错误很多页面,但无法找到任何东西:
- cat file_name | grep "something" results "cat: grep: No such file or directory" in shell scripting
- Pipe multiple commands to a single command with no EOF signal wait
- grep command works in command line, but not in bash script: get no such file or directory erro
- https://serverfault.com/questions/169539/sed-cant-find-a-file-that-obviously-exists
- "No such file or directory" but it exists
如果您认为等待或睡眠命令有帮助,请告诉我。或者,如果您认为有更好的解决方案,那也会很棒。我在Cygwin终端上运行。任何见解都非常感谢。
你打算要在文件名中一片空白,从第一个“sed的”? – phreed
你说这个脚本重复运行。运行之间file3.txt是否被删除?这两次运行是否可能是并发的?我想知道'sed -i'。 – phreed
每当我看到一大堆临时文件,有多种用法的grep和sed,我想到了awk。我不知道你为什么没有工作,但我几乎可以确定你要做的事情可以简化为一个awk脚本。如果您向我们展示您的输入和您期望的输出,那么我们可以更有效地帮助您。 –