Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.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 与&;和-在狂欢节上_Bash_Unix_Posix - Fatal编程技术网

Bash 与&;和-在狂欢节上

Bash 与&;和-在狂欢节上,bash,unix,posix,Bash,Unix,Posix,据我所知,&&和-a都在BASH shell的表达式中提供了条件和函数 它们之间有什么区别吗?是的,-a和-o是。根据您的输入,它们可能会中断,因此不应使用。一些区别: 和/或&&而非-a的列表: false && echo foo || echo bar true || echo foo && echo bar [ -d directory ] || mkdir directory -a是mor limited,作为test命令的一部分:with test或i

据我所知,
&&
-a
都在BASH shell的表达式中提供了条件
函数


它们之间有什么区别吗?

是的,
-a
-o
是。根据您的输入,它们可能会中断,因此不应使用。

一些区别:

和/或&&而非-a的列表:

false && echo foo || echo bar
true || echo foo && echo bar
[ -d directory ] || mkdir directory
-a是mor limited,作为test命令的一部分:with test或in[[,

test -d mydir -a -f somefile
[  -d mydir -a -f somefile  ] 

-a和-o也是find命令语法的一部分

还有其他区别,与shell语法有关,而与POSIX无关suppport@jimmcnamaraOP声明他们知道这两个方面,所以我认为可以安全地假设语法差异是已知的。而且,链接文档清楚地显示了语法和其他方面的差异。双精度括号符号
[
不理解
-a
-o
,只有
[
理解。相反,[-f t.lis&&f t.dat]生成语法错误。