小编sup*_*sky的帖子

没有左边的“如果”,方括号是什么意思?

据我所知,方括号通常用于将表达式括在 if else 语句中。

但我发现方括号没有“if”,如下所示:

[ -r /etc/profile.d/java.sh ] && . /etc/profile.d/java.sh
Run Code Online (Sandbox Code Playgroud)

在下面的脚本中。

#!/bin/bash### BEGIN INIT INFO  
# Provides:          jbossas7  
# Required-Start:    $local_fs $remote_fs $network $syslog  
# Required-Stop:     $local_fs $remote_fs $network $syslog  
# Default-Start:     2 3 4 5  
# Default-Stop:      0 1 6  
# Short-Description: Start/Stop JBoss AS 7  
### END INIT INFO  
# chkconfig: 35 92 1  

## Include some script files in order to set and export environmental variables  
## as well as add the appropriate executables to …
Run Code Online (Sandbox Code Playgroud)

shell bash

72
推荐指数
2
解决办法
9万
查看次数

标签 统计

bash ×1

shell ×1