shell 使工作自動化容易

再來看一個簡單的例子:cleanup (取自:Advanced Bash-Scripting Guide / 作者:Mendel Coope)

#! /bin/sh
# cleanup
# Run as root, of course.

cd /var/log
cat /dev/null > messages
cat /dev/null > wtmp
echo "Logs cleaned up."

這支程式用來清除 /var/log 目錄中的系統記錄檔,工作自動化很簡單不是?這是 shell script 的威力。