FDD-book/src/chapters/3/ifs/ifs.sh
Edson Brandi c7c03a1da2
Add Chapter 3 shell scripting examples
Add comprehensive shell scripting examples covering fundamental concepts:
- Basic scripts: hello.sh, vars.sh, status.sh
- Control flow: case.sh, loops.sh
- Functions and debugging: functions.sh, debug_demo.sh
- File handling: list_files variants (POSIX, bash, exec approaches)
- Practical utilities: backup.sh, organize_downloads.sh
- Advanced topics: IFS handling, temporary file management

These examples demonstrate portable shell scripting practices for
FreeBSD driver development workflows.
2025-11-07 22:00:05 +00:00

24 lines
382 B
Bash
Executable file

#!/bin/sh
# ifs.sh demonstrate file and numeric tests
file="/etc/rc.conf"
# -f tests if a regular file exists
if [ -f "$file" ]; then
echo "$file exists"
else
echo "$file does not exist"
fi
num=5
if [ "$num" -gt 3 ]; then
echo "$num is greater than 3"
fi
# String tests
user="$(whoami)"
if [ "$user" = "root" ]; then
echo "You are root"
else
echo "You are $user"
fi