Unix & Linux: What do square brackets mean without the "if" on the left? (2 Solutions!!)

0
100

Unix & Linux: What do square brackets mean without the “if” on the left?

The Question: As far as I know, square brackets are used to enclose an expression usually in
if else statements.
But I found square brackets being used without the “if” as follows:
[ -r /etc/profile.d/java.sh ] && . /etc/profile.d/java.sh
in the following script.
#!/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 $PATH.
[ -r /etc/profile.d/java.sh ] && . /etc/profile.d/java.sh
[ -r /etc/profile.d/jboss.sh ] && . /etc/profile.d/jboss.sh

JBOSS_HOME=/sw/AS7

AS7_OPTS=”$AS7_OPTS –
Dorg.apache.tomcat.util.http.ServerCookie.ALLOW_HTTP_SEPARATORS_IN_V0=true”
## See AS7-1625
AS7_OPTS=”$AS7_OPTS -Djboss.bind.address.management=0.0.0.0″
AS7_OPTS=”$AS7_OPTS -Djboss.bind.address=0.0.0.0″

case “$1” in
start)
echo “Starting JBoss AS 7…”
#sudo -u jboss sh ${JBOSS_HOME}/bin/standalone.sh $AS7_OPTS
## If running as user “jboss”
#start-stop-daemon –start –quiet –background –chuid jboss –exec $
{JBOSS_HOME}/bin/standalone.sh $AS7_OPTS ## Ubuntu
${JBOSS_HOME}/bin/standalone.sh $AS7_OPTS &
;;
stop)
echo “Stopping JBoss AS 7…”
#sudo -u jboss sh ${JBOSS_HOME}/bin/jboss-admin.sh –connect command=:
shutdown ## If running as user “jboss”
#start-stop-daemon –start –quiet –background –chuid jboss –exec $
{JBOSS_HOME}/bin/jboss-admin.sh — –connect command=:shutdown ## Ubuntu
${JBOSS_HOME}/bin/jboss-cli.sh –connect command=:shutdown
;;
*)
echo “Usage: /etc/init.d/jbossas7 {start|stop}”; exit 1;
;;
esac
… (Please watch the video for the full question)

Solutions: Please watch the whole video to see all solutions, in order of how many people found them helpful

With thanks & praise to God, and with thanks to the many people who have made this project possible! | Content (except music & images) licensed under cc by-sa 3.0 | Music: | Images: & others | With thanks to user supertonsky ( user slm ( user Mike Diehn ( and the Stack Exchange Network ( Trademarks are property of their respective owners. Disclaimer: All information is provided “AS IS” without warranty of any kind. You are responsible for your own actions. Please contact me if anything is amiss at Roel D.OT VandePaar A.T gmail.com.

source

LEAVE A REPLY

Please enter your comment!
Please enter your name here