ls "${VMX_DIR}" | grep -q delta > /dev/null 2>&1;
It lists the files in VMX_DIR and then pipes them into grep but what is it doing?
|
|
|
It's checking to see whether there is a file or path containing Here's what it's doing statement by statement:
Lists the contents of the directory stored in the path
Pipe the results to grep, searching the results of the directory listing for
Redirects stdout to |
||||
|
|
|
From the
Basically this is looking to see if there is a filename containing |
|||
|
|
|
It seems like it is meant to just detect if the word 'delta' is in the list, in which case it will return 0, otherwise it will return 1. So, based on the return value, you know if delta was there or not. |
|||
|
|
|
The last part redirects standard output and standard error to /dev/null - I.e., any output of the grep command (errors, warnings, or matches) is dropped. This kind of command can be useful to do a simple check with no output - The You could simplify this code by replacing See I/O Redirection for details. |
||||
|
|