Shell script

AXISHK
AXISHK used Ask the Experts™
on
What does these two line in shell script mean ? What's the usage for "[ ]" and "&&" ?

  [ $RETVAL = 0 ] && rm -f $lockfile
  return $RETVAL
Tks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
ozo
Most Valuable Expert 2014
Top Expert 2015

Commented:
see
man test
Zephyr ICTCloud Architect
Commented:
[ ] are used in the shell for performing a conditional test.

&& is used between two command, as AND operator, if 2 commands have && between them, the command on the left (command1) is run first, and the command on the right (command2) is run only if the first command succeeds --> command1 && command2
Most Valuable Expert 2014
Top Expert 2015
Commented:
man bash
       The control operators && and || denote AND lists and OR lists, respectively.  An AND list has the form

              command1 && command2

       command2 is executed if, and only if, command1 returns an exit status of zero.

Author

Commented:
Tks

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial