April 2018
Beginner
284 pages
7h 3m
English
If we need to open a file from within our script, we test that the file is both a regular file and has the read permission set. To achieve this with test, we can also include the -a option to AND multiple conditions together. In the following example command, we will use the -r condition to check that the file is readable:
$ test -f /etc/hosts -a -r /etc/hosts
Similarly, the use of -o is supported to OR two conditions within an expression.