mirror of
https://github.com/ebrandi/FDD-book.git
synced 2026-12-06 00:23:30 +00:00
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.
24 lines
382 B
Bash
Executable file
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
|