Skip to content

Instantly share code, notes, and snippets.

View stoyanovgeorge's full-sized avatar
🎯
Focusing

Georgi Stoyanov stoyanovgeorge

🎯
Focusing
  • Techtriq GmbH
  • Germany
View GitHub Profile
@stoyanovgeorge
stoyanovgeorge / var_integer.sh
Last active August 20, 2018 10:45
Check if $var is integer or not
#!/bin/bash
if [[ "$var" =~ ^-?[0-9]+$ ]];then
echo "integer"
else
echo "not integer"
fi
@stoyanovgeorge
stoyanovgeorge / ping_check.sh
Last active August 20, 2018 10:46
Check whether a host is replying to ICMP requests or not. Usage: ./script.sh 192.168.1.1
#!/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"
@stoyanovgeorge
stoyanovgeorge / random_number_range.sh
Last active August 20, 2018 10:46
Bash script which generates random number in a range [0 : 500]
#!/bin/bash
range=500
number=$RANDOM
let "number %= $range"
printf "Random number less than %s - %s\n" "$range" "$number"