Some Bash Programs
Some Bash Programs
Some Bash Programs
These programs provide a range of use cases, from user management and system monitoring
to practical automation and string manipulation. Below are 30 Bash scripts for common use
cases, categorized into different functionalities:
1. Hello World
#!/bin/bash
echo "Hello, World!"
3. Factorial Calculation
#!/bin/bash
echo "Enter a number:"
read num
fact=1
for (( i=1; i<=num; i++ )); do
fact=$(( fact * i ))
done
echo "Factorial of $num is $fact"
6. Reverse a String
#!/bin/bash
echo "Enter a string:"
read str
echo "$str" | rev
7. Palindrome Check
#!/bin/bash
echo "Enter a string:"
read str
if [[ "$str" == "$(echo $str | rev)" ]]; then
echo "$str is a palindrome."
else
echo "$str is not a palindrome."
fi
#!/bin/bash
echo "Scheduling a job..."
echo "* * * * * /path/to/script.sh" | crontab -