man コマンド

man コマンドとは

man はUNIXにおいてテキストベースのオンラインマニュアルを見るためのコマンドである。
UNIXでは、使用方法のわからないコマンドがあったら、まずmanコマンドで調べる。
多くのマニュアルは日本語で表示されるが、一部英語のものもある。

man コマンドの使い方

以下の使用方法で[ ]で囲まれている部分は省略可能(オプション)である。
UNIXではオプションは - (ハイフン)の後に英数字1文字で表されることが多い。(例外あり)

man [-f] [-k] [セクション] コマンド名またはキーワード ...
-f
コマンドの使い方だけ表示する。
whatisコマンドと同じ。
-k
キーワードで探す。
そのキーワードに関係のあるコマンドの一覧が表示される。
セクション
マニュアルの種類を表す番号
コマンド名またはキーワード ...
調べたいコマンドの名前や、キーワード
後ろについている ... はコマンド名・キーワードが複数あっても良いことを表す。

コンソールの1画面より長いマニュアルを表示する場合はSpaceを押すと次の画面に進む。

manコマンドの使用例

calというコマンドをmanコマンドで調べてみよう。

% man cal



名称
     cal - カレンダを表示する

書式
     cal [-jy] [[month] year]

解説
     cal は簡単なカレンダを表示します。もし引数が指定されなかった場合は今月の
     ものを表示します。オプションは以下のものがあります:

     -j      ユリウス歴で表示します (日にちは 1 月 1 日からの日数です)。

     -y      今年のカレンダを表示します。

     パラメータを 1 つだけ指定した場合には、その数値の年 (1 - 9999) のカレンダ
     を表示します。ただし、年は完全な形で指定して下さい。例えば ``cal 89'' で
     は 1989 年のカレンダーを表示 しません。パラメータ 2 つで月 (1 - 12) と年
     を表します。パラメータを指定しない場合はその月のカレンダが表示されます。

     1 年は 1 月 1 日から始まります。

     グレゴリオ暦への切り替えは 1752 年の 9 月 3 日に行われたと仮定していま
     す。この時にほとんどの国が切り替えを承認しました (ただし 1900 年初頭まで
     承認しなかった国も、僅かながらありました)。この切り替えにより、この日から
     10 日間が無視されたため、この月のカレンダは少し変になっています。

使用例
     以下に cal の利用例を示します。

           $ cal
                April 1995
            S  M Tu  W Th  F  S
                              1
            2  3  4  5  6  7  8
            9 10 11 12 13 14 15
           16 17 18 19 29 21 22
           23 24 25 26 27 28 29
           30
           $ cal -j
                   April 1995
             S   M  Tu   W  Th   F   S
                                    91
            92  93  94  95  96  97  98
            99 100 101 102 103 104 105
           106 107 108 109 110 111 112
           113 114 115 116 117 118 119
           120
           $ cal 9 1752
             September 1752
            S  M Tu  W Th  F  S
                  1  2 14 15 16
           17 18 19 20 21 22 23
           24 25 26 27 28 29 30

歴史
     cal コマンドは Version 6 AT&T UNIX から登場しました。


書式の部分にある[-jy]はオプションとして-jと-yがあることを示している。
[[month] year]は月日を表す時にyearまたはmonth yearの2通りがあることを表す。

参考までに同じコマンドを英語で表示させた場合は以下のようになる。



CAL(1)                       UNIX Reference Manual                      CAL(1)

NAME
     cal - displays a calendar            ← コマンドの名前と目的(名称)

SYNOPSIS
     cal [-jy] [month [year]]             ← コマンドの使用形式(書式)

DESCRIPTION                               ← コマンドの説明(解説)
     Cal displays a simple calendar.  If arguments are not specified, the cur-
     rent month is displayed.  The options are as follows:

     -j      Display julian dates (days one-based, numbered from January 1).

     -y      Display a calendar for the current year.

     A single parameter specifies the year (1 - 9999) to be displayed; note
     the year must be fully specified: ``cal 89'' will not display a calendar
     for 1989.  Two parameters denote the month (1 - 12) and year.  If no pa-
     rameters are specified, the current month's calendar is displayed.

     A year starts on Jan 1.

     The Gregorian Reformation is assumed to have occurred in 1752 on the 3rd
     of September.  By this time, most countries had recognized the reforma-
     tion (although a few did not recognize it until the early 1900's.)  Ten
     days following that date were eliminated by the reformation, so the cal-
     endar for that month is a bit unusual.

HISTORY                               ← コマンドの歴史
     A cal command appeared in Version 6 AT&T UNIX.

BSD Experimental                 June 6, 1993                                1

次にmanコマンドをmanコマンドの-fオプションで調べてみよう。

% man -f man

man (1)              - an interface to the on-line reference manuals
man (7)              - macros to format man pages

manという同じ名前で2種類表示されているが最初のものが上で見たmanコマンドである。
2番目は同じ名前でも違う種類のものである。 (マニュアルを表示する時に使用するマクロというもの)
(1)、(7)などの番号はセクションというコマンド・キーワードの種類を表すものである。
もし(7)の方のマニュアルを表示したい時は以下のように実行する。

% man 7 man

次にdateというキーワードで-kオプションを使って関係のあるコマンドを一覧表示してみると以下のようになる。

% man -k date
localtime (3)        - transform binary date and time to ASCII
gmtime (3)           - transform binary date and time to ASCII
netdate (8)          - set date and time by ARPA Internet RFC 868
822-date (1)         - Print date and time in RFC822 format
ftime (3)            - return date and time
mktime (3)           - transform binary date and time to ASCII
date (1)             - print or set the system date and time
asctime (3)          - transform binary date and time to ASCII
ctime (3)            - transform binary date and time to ASCII
strftime (3)         - format date and time
rdate (8)            - set the system's date from a remote host

セクション

番号種類
1一般ユーザーの実行するコマンド
2システムコール
3C言語の関数(ライブラリ)
4デバイスファイル(/dev)
5システム設定ファイルのフォーマット
6ゲーム
7manコマンドなどのマクロパッケージ
8システム管理コマンド

参考


Prev
Home | Contents
abe@injapan.net