我要如何查詢指令的說明?
為了瞭解各個指令的用途,早期大家會使用 man 指令(「manual」的縮寫)。例如,執行 man head 會顯示以下資訊:
HEAD(1) BSD General Commands Manual HEAD(1)
NAME
head -- display first lines of a file
SYNOPSIS
head [-n count | -c bytes] [file ...]
DESCRIPTION
This filter displays the first count lines or bytes of each of
the specified files, or of the standard input if no files are
specified. If count is omitted it defaults to 10.
If more than a single file is specified, each file is preceded by
a header consisting of the string ``==> XXX <=='' where ``XXX''
is the name of the file.
SEE ALSO
tail(1)
man 會自動呼叫 less,所以你可能需要按空白鍵往下翻頁,並用 :q 離開。
NAME 底下那一行會用一句話簡短說明指令的功能,而 SYNOPSIS 的摘要則列出所有可用旗標。方括號 [...] 表示選用項目,選擇其一的替代關係用 | 分隔,可以重複的項目以 ... 表示。因此,head 的手冊頁面告訴你:你可以用 -n 指定行數,或用 -c 指定位元組數,二擇一,且可以提供任意數量的檔名。
Unix 手冊的缺點是你必須先知道自己在找什麼。如果不知道,你可以搜尋 Stack Overflow(https://stackoverflow.com/)、在 DataCamp 的 Slack 頻道發問,或查看你已熟悉指令的 SEE ALSO 區段。
本練習屬於課程
