This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [[ "$var" =~ ^-?[0-9]+$ ]];then | |
echo "integer" | |
else | |
echo "not integer" | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# check if the $1 is empty | |
if [[ -z "$1" ]];then | |
printf "Please define the IP or the hostname which you want to check!\nUsage: ./script.sh 192.168.1.1\n" | |
else | |
if ping -c 1 "$1" &> /dev/null;then | |
printf "%s is UP!\n" "$1" | |
else | |
printf "%s is DOWN!\n" "$1" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
range=500 | |
number=$RANDOM | |
let "number %= $range" | |
printf "Random number less than %s - %s\n" "$range" "$number" |
NewerOlder