Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/16.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 为什么重定向在我的shell脚本中不起作用?_Bash_Shell_Io Redirection - Fatal编程技术网

Bash 为什么重定向在我的shell脚本中不起作用?

Bash 为什么重定向在我的shell脚本中不起作用?,bash,shell,io-redirection,Bash,Shell,Io Redirection,我试图找到关键字并将它们重定向到文件。我可以在终端上看到结果,但这些结果不会在txt文件中重定向 find /opt/IBM /opt/ibm /usr/IBM /usr/ibm \( -name db2licm -o -name onstat -o -name versionInfo.sh -o -name WPVersionInfo.sh \) 2>>/tmp/versiondocument.txt 我希望versiondocument.txt中db2licm,versioni

我试图找到关键字并将它们重定向到文件。我可以在终端上看到结果,但这些结果不会在txt文件中重定向

find /opt/IBM /opt/ibm /usr/IBM /usr/ibm \( -name db2licm -o -name onstat -o -name versionInfo.sh -o -name WPVersionInfo.sh \) 2>>/tmp/versiondocument.txt

我希望
versiondocument.txt中
db2licm
versioninfo.sh
的路径是
versiondocument.txt
您只能使用
2>
重定向错误。请尝试以下示例:

$find
.
/b
/b/file.txt
/b/b.txt
/a
/a/a.txt
/a/c.txt
/tmp.log
$find a b-name file.txt-o-name a.txt>>tmp.log
$cat tmp.log
a/a.txt
b/file.txt

你需要转义parensa你可以看到,在OP的调用中parens(
)(
)是转义的,但在你的调用中它们不是,你说它是OP的mistake@oguzismail不,第一篇文章(编辑之前)没有转义的
()
。所以我的回答是正确的:p我已经移除了它。好吧,那么,移除了我的