Quantcast
Channel: Bashタグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 2828

コマンドがどこにあるのかを調べる

$
0
0
whichコマンド 概要 man whichすると、 which ユーティリティは、コマンド名のリストを受け取り、それらのコマンドが実際に起動された場合に実行されるであろう各実行ファイルのパスを検索します。と書いてました。 使ってみた lsコマンドの場所を探す場合、以下のようにします。 % which ls /bin/ls brewコマンドを探す場合 % which brew /opt/homebrew/bin/brew -aオプションで同名のコマンドがあれば、全表示出来ます。 whichコマンドはビルトインコマンドと/usr/bin/whichの2つがあるそうです。 % which -a which which: shell built-in command /usr/bin/which typeコマンド typeコマンドでも同じようなことが出来るそうです。 % type ls ls is /bin/ls % type brew brew is /opt/homebrew/bin/brew -aオプション typeも同じですね。 % type -a type type is a shell builtin type is /usr/bin/type whenceコマンド もう1つ同じようなコマンドがあるそうなので使ってみました。 whence コマンド名でコマンドを実行した際に、呼び出されるコマンドを表示してくれます。 % whence ls /bin/ls whence -cはwhichと同じ % whence -c ls /bin/ls whence -vはtypeと同じ whence -v ls ls is /bin/ls

Viewing all articles
Browse latest Browse all 2828

Latest Images

Trending Articles