Set your Publisher ID in src/config/ads.ts to display live ads.
Conditional Logic: [ ... ] vs [[ ... ]]
String comparisons (=, !=, -z), integer tests (-eq, -lt), and file checks (-f, -d)
Conditional statements in Bash use the test command or modern double brackets [[ ... ]] for string, integer, and file system evaluations.
Comparison Operators & Double Brackets
String comparisons: ==, !=, -z (checks if string is empty), -n (not empty).
Integer comparisons: -eq (equal), -ne (not equal), -lt (less than), -gt (greater than).
File system tests: -f (regular file exists), -d (directory exists), -s (file exists and not empty).
Best Practice: Always use [[ ... ]] over legacy [ ... ] because it prevents word splitting and supports regex matching (=~).
#!/usr/bin/env bash
CONFIG_FILE="/etc/app/config.json"
if [[ -f "$CONFIG_FILE" ]]; then
echo "Configuration file found. Starting service..."
elif [[ -d "/etc/app" ]]; then
echo "Directory exists, but config.json is missing!"
else
echo "Error: Application is not installed."
exit 1
fiSet your Publisher ID in src/config/ads.ts to display live ads.
Test Yourself With Exercise
Which file test operator in Bash checks if a path exists AND is a regular file?