I found the following command in the .profile file while installing node through nvm:[ -s $NVM_DIR/nvm.sh ] && . $NVM_DIR/nvm.sh I want to know what is the the purpose of [] and && in the following command.I have not encountered this command syntax before, and I want to understand, what is the following command doing, and what is the syntax called?My guess is that it is creating a soft link, am I right?EDIT: nvm.sh is not an executable file.
what is the command [ -s $NVM_DIR/nvm.sh ] && . $NVM_DIR/nvm.sh doing
bash;bashrc;profile
The [ is a test construct:$ help [[: [ arg... ]    Evaluate conditional expression.    This is a synonym for the test builtin, but the last argument must    be a literal `]', to match the opening `['.The -s is one of the available tests, it returns true if the file both exists and is not empty:$ help test | grep -- -s      -s FILE        True if file exists and is not empty.The && is the AND operator. It will run the command on the right only if the command on the left was successful. Finally, the . is the source command which tells the shell to evaluate any code in the sourced file within the same shell session:$ help ..: . filename [arguments]    Execute commands from a file in the current shell.    Read and execute commands from FILENAME in the current shell.  The    entries in $PATH are used to find the directory containing FILENAME.    If any ARGUMENTS are supplied, they become the positional parameters    when FILENAME is executed.So, the command you posted is the same as:## If the file exists and is not emptyif [ -s $NVM_DIR/nvm.sh ]; then    ## Source it    . $NVM_DIR/nvm.shfi