| -b file | True if file exists and is a block special file |
| -c file | True if file exists and is a character special file |
| -d file | True if file exists and is a directory |
| -e file | True if file exists |
| -f file | True if file exists and is a regular file |
| -G file | True if file exists and is owned by the effective group ID |
| -g file | True if file exists and has SGID set |
| -k file | True if file exists and has its "sticky" bit set |
| -l file | True if file exists and is a symbolic link |
| -O file | True if file exists and is owned by effective ID |
| -p file | True if file exists and is a named pipe |
| -r file | True if file exists and is a readable |
| -S file | True if file exists and is a socket |
| -s file | True if file exists and has a size greater than zero |
| -u file | True if file exists and has SUID set |
| -w file | True if file exists and is writable |
| -x file | True if file exists and is executable |
| file1 -ef file2 | True if both files have the same device and inode numbers |
| file1 -nt file2 | True if file1 is newer (modification date) than file2 |
| file1 -ot file2 | True if file1 is older (modification date) than file2 |
| string1 -a string2 | True if both expressions are true |
| string1 -o string2 | True if either expressions are true |
| -z string | True if the length of string is zero |
| -n string | True if the length of string is non-zero |
| string1 = string2 | strings are equal |
| string1 != string2 | strings not are equal |
| integer1 -eq integer2 | True if integers are equal |
| integer1 -ge integer2 | True if integer1 is greater than or equal to integer2 |
| integer1 -gt integer2 | True if integer1 is greater than integer2 |
| integer1 -lt integer2 | True if integer1 is less than integer2 |
| integer1 -le integer2 | True if integer1 is less than or equal to integer2 |
| integer1 -ne integer2 | True if integer1 is not equal to integer2 |
| declare -a ARRAY_1=( element1 element2 element3 ...elementN ) | Create an Array in one line |
| echo ${#ARRAY_1[@]} | Print the number of elements in the array |
| echo ${ARRAY_1[@]} | Print all the elements in the array |
| echo ${ARRAY_1[3]} | Print one element in the array( example prints 4th element, first is 0) |
if [ -z "$<variable>" ]; then
while [ -z "$<variable>" ]
do
....(some code)...
done
fi
for i in word1 word2 ...wordn
do
action involving $i (which = word)
done
NEW_VARIABLE="`/sbin/ifconfig -a|grep -A 2 eth0|awk '/inet/ { print $2 }'|sed -e s/addr://`"
# build the Message & Subject variables
echo "No major canges in disk use on $HOSTNAME" > $MESSAGE
echo " " >> $MESSAGE
echo "`cat $DISKUSE`" >> $MESSAGE
echo "$HOSTNAME - Disk Space Report" > $SUBJECT
# send the message to address $EMAIL
echo "`cat $MESSAGE`" | mail -s "`cat $SUBJECT`" $EMAIL
if [ -s $DIFFTEST ] ;then
if [ $SCHEDULED == $ACTUAL ] ;then
# get external address from by greping ifconfig
EXIP="`ifconfig -a|grep -A 2 $EXIF|awk '/inet/ { print $2 }'\
|sed -e s/addr://`"
EXBCAST="`ifconfig -a|grep -A 2 $EXIF|awk '/inet/ { print $3 }'\
|sed -e s/Bcast://`"
# get dns servers from resolv.conf file
# first line is path, next 3 are dns servers
NAMED1="`cat /etc/resolv.conf|grep -n nameserver|grep 2:\
|sed -e s/nameserver//|sed -e s/2://`"
NAMED2="`cat /etc/resolv.conf|grep -n nameserver|grep 3:\
|sed -e s/nameserver//|sed -e s/3://`"
NAMED3="`cat /etc/resolv.conf|grep -n nameserver|grep 4:\
|sed -e s/nameserver//|sed -e s/4://`"
for x in `ls -1|sed -e s/"\ "/_/g`;do mv "`echo $x|sed -e s/_/"\ "/g`" ${x};done