White space

The fact that [[ is not a command is significant where white space is concerned. As a keyword, [[ parses its arguments before bash expands them. As such, a single parameter will always be represented as a single argument. Even though it goes against best practice, [[ can alleviate some of the issues associated with white space within parameter values. Reconsidering the condition we tested earlier, we can omit the quotes when using [[, as shown in the following example:

$ echo "The File Contents">"my file"
$ FILE="my file"
$ [[ -f $FILE && -r $FILE ]] && cat "$FILE"

We still need to quote the parameter when using cat, as you can see, and we can use quotes within the double brackets but they become optional. Note that we can also use the more traditional && and || to represent -a and -o respectively.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.217.5.86