Combining Tests || &&
Combining Tests It is possible to combine tests by using the && and || operators. These perform a Logical AND and Logical OR, respectively. #!/bin/bash filename=${1:-/etc/hosts} if [ -r “$filename” ] && [ -s “$filename” ]; then md5sum $filename else echo “$filename can not be processed” fi # Show the file if possible ls -ld $filename 2>/dev/null ----------- cat f filename=$1 [ -r $filename ] || echo “$filename is not readable” bash f /etc/shadow “/etc/shadow is not readable” ubuntu2@ubuntu2:~/Documents/shellscripting$ bash f t/ cat f filename=$1 [ -r $filename ] && echo “$filename is readable” bash f t/ “t/ is readable” ubuntu2@ubuntu2:~/Documents/shellscripting$ bash f /etc/shadow ----------------