Categories
Programming

Test if files exists

Searches in $directory for any files that begin with $today. If it find any files the script will exit.

[code language=”bash”]
#!/bin/bash

if [ $daily -eq "1" ] ; then
if ! find $directory -type f -name "$today*" -exec false {} + ; then
exit;
fi;
fi;
[/code]

Categories
Programming

Test if pingable

The code snippet belows try to ping $host. if ping fails (ping returns none zero value exitcode) the script exits.

[code language=”bash”]
#!/bin/bash
if [ $ping -eq "1" ] ; then
if ! ping -w 4 -c 1 $host > /dev/null 2>&1 ; then
exit
fi;
fi;
[/code]