Files

32 lines
545 B
Bash
Executable File

#!/bin/bash
if ls -d /tmp; then
echo "Command succeeded: file exists."
fi
if [ -f /etc/hosts ]; then
echo "/etc/hosts exists"
fi
num=100
if [ "$num" -gt 10 ]; then
echo "The number is greater than 10."
fi
floatnum=20.34
result=$(echo "$floatnum > 10.5" | bc)
if [ "$result" -eq 1 ]; then
echo "The number is greater than 10.5"
fi
word="hello"
if [ "$word" = "hello" ]; then
echo "You typed hello."
fi
sentense="I want to say hello to the world"
regex="say.*hello"
if [[ "$sentense" =~ $regex ]]; then
echo "Substring found."
fi