December 1999
Beginner
528 pages
11h 10m
English
There are two general formats of the test and you can use either:
test condition
or
[ condition ]
Please note the use of a space each side of the condition when using square brackets.
The conditions to which you can test the file’s status are quite long, but Table 17.1 lists the most common ones.
| -d | This is a directory |
| -f | This is a regular file |
| -L | This is a symbolic link |
| -r | This file is readable |
| -s | This file has a size greater than zero, not empty |
| -w | This file is writeable |
| -u | This file has the suid bit set |
| -x | This is executable |
We will use both test methods to test if the file scores.txt is writeable. We will use the last status command to test it. Remember a zero status is OK, ...
Read now
Unlock full access