TYPEはLinuxコマンドであり、入力コマンドがエイリアス、組み込み、関数、またはキーワードであるかどうかを識別するのに役立ちます。入力パラメータとして複数のコマンドを渡すこともできます。
このコマンドのすべての引数はオプションです。
基本的な構文を以下に示します。
type [-afptP] name [name ...]
ここで
[afptP]
-a - display all locations containing an executable named NAME; includes aliases, builtins, and functions, if and only if the '-p' option is not also used -f - suppress shell function lookup -P - force a PATH search for each NAME, even if it is an alias, builtin, or function, and returns the name of the disk file that would be executed -p - returns either the name of the disk file that would be executed or nothing if `type -t NAME' would not return `file'. -t - output a single word which is one of `alias', `keyword', `function', `builtin', `file' or `', if NAME is an alias, shell reserved word, shell function, shell builtin, disk file, or not found, respectively
名前 –解釈されるコマンド名。
終了ステータス –すべてのNAMEが見つかった場合、成功を返します。見つからない場合は失敗します。
タイプコマンドの使用方法
Linux、Unix、およびUnixライクなシステムコマンドでは、エイリアス、シェルビルトイン、ファイル、関数、またはキーワードを使用できます。では、シェルで実行しているコマンドの種類を見つける方法。
pwdコマンドを検討してください。それはシェルビルトインですか、それとも関数ですか?
シェルは、これを見つけるための固有のコマンドタイプを提供します。 Linuxターミナルを開き、以下に示すようにコマンドを実行します。
$ type -a pwd pwd is a shell builtin
出力は、pwdがシェルビルトインであることを示しています。
lsコマンドはどうですか?
type ls ls is aliased to `ls --color=auto'
lsはエイリアスです。
タイプ自体はシェルビルトインです。これは、それ自体で実行することで見つけることができます。
$ type type type is a shell builtin
タイプコマンドの例
ここで、例とともにすべてのオプションについて説明します。
1. -aオプションは、NAMEという名前の実行可能ファイルを含むすべての場所とそのタイプを表示します。
$ type -a pwd pwd is a shell builtin pwd is /bin/pwd
このコマンドへの入力として、コマンドの複数の名前を渡すこともできます。
$ type -a pwd wc pwd is a shell builtin pwd is /bin/pwd wc is /usr/bin/wc wc is /usr/bin/wc
2. -fオプションは、シェル関数のルックアップを抑制します。
$ type -f pwd pwd is a shell builtin
3. -pは、エイリアス、ビルトイン、または関数の完全なパスとともに実行されるディスクファイルの名前を返します。
$ type -p wc /usr/bin/wc
4. -tオプションは、組み込み、関数、エイリアスなどのタイプを返すだけです
$ type -t pwd builtin
概要
そこで、LinuxTypeコマンドの基本的な動作を例で説明しました。いつでも、ヘルプが必要な場合は、ターミナルでmanを実行するか、ヘルプを入力してください。
コマンドについては、このオンラインマニュアルを参照してください。