なぜ押し出せないのですか?

なぜ押し出せないのですか?

私はbashスクリプトを書くときに長い間pushdandを使ってきました。popdしかし、今日実行してもwhich pushd何の結果も出ません。私はこれを理解できません。私はいつもそれがwaitのpushdような単純なコマンドだと思いました。cdls

それではなぜwhich pushd私には何も与えられなかったのでしょうか。

ベストアンサー1

popdこれはpushdBashに組み込まれたコマンドであり、実際のバイナリとしてHDDに存在する実際の実行可能ファイルではありません。

Bashのマニュアルページから抜粋
   DIRSTACK
          An array variable (see Arrays below) containing the current 
          contents of the directory stack.  Directories appear in the stack 
          in the order they are displayed by the dirs builtin.  Assigning to 
          members of  this  array variable may be used to modify directories 
          already in the stack, but the pushd and popd builtins must be used 
          to add and remove directories.  Assignment to this variable will 
          not change the current directory.  If DIRSTACK is unset, it loses 
          its special properties, even if it is subsequently reset.

すべての組み込みコマンドの完全なリストは、Bashのマニュアルページとここにあります。http://struct.usc.edu/bash/bashref_4.html

compgen -bまたはを使用して、enableこれらすべての組み込み関数の完全なリストを取得することもできます。

キャンプゲン
$ compgen -b | grep -E "^push|^pop"
popd
pushd
〜できるようにする
$ enable -a | grep -E "\bpop|\bpus"
enable popd
enable pushd

また、組み込みコマンドのサポートが必要な場合は、次のものを使用できますhelp

$ help popd | head -5
popd: popd [-n] [+N | -N]
    Remove directories from stack.

    Removes entries from the directory stack.  With no arguments, removes
    the top directory from the stack, and changes to the new top directory.

$ help pushd | head -5
pushd: pushd [-n] [+N | -N | dir]
    Add directories to stack.

    Adds a directory to the top of the directory stack, or rotates
    the stack, making the new top of the stack the current working

おすすめ記事