透過處理訂單日誌實戰,示範 8 個核心 Linux 指令用法,適合初學者快速上手。
order.out.log
8:22:19 111, 1, Patterns of Enterprise Architecture, Kindle edition, 39.99
8:23:45 112, 1, Joy of Clojure, Hardcover, 29.99
8:24:19 113, -1, Patterns of Enterprise Architecture, Kindle edition, 39.99
order.in.log
8:22:20 111, Order Complete
8:23:50 112, Order sent to fulfillment
8:24:20 113, Refund sent to processing
cat order.out.log # 顯示單一檔案
cat order.* # 串接所有 order 開頭檔案
cat order.* | sort # 合併後按時間排序
大量日誌時,建議搭配管道傳遞給過濾工具(如 grep、awk)進一步處理。
後續將介紹 grep、awk、sed、cut、uniq、wc、find 等指令進階用法。