Why can't I which pushd

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












I've been using pushd and popd for a long time while writing bash script. But today when I execute which pushd, I get nothing as output. I can't understand this at all. I was always thinking that pushd is simply a command, just like cd, ls etc.



So why does which pushd give me nothing?










share|improve this question

















  • 1




    Related: How to distinguish between builtin and external util? (e.g. echo)
    – steeldriver
    Aug 8 at 1:16










  • Related: unix.stackexchange.com/q/85249/117549
    – Jeff Schaller
    Aug 8 at 1:17










  • Further to Jeff Schaller's note: observe that in some shells which pushd does not yield nothing, but rather yields pushd: shell built-in command, and the premise of the question is wrong.
    – JdeBP
    Aug 8 at 10:26














up vote
1
down vote

favorite












I've been using pushd and popd for a long time while writing bash script. But today when I execute which pushd, I get nothing as output. I can't understand this at all. I was always thinking that pushd is simply a command, just like cd, ls etc.



So why does which pushd give me nothing?










share|improve this question

















  • 1




    Related: How to distinguish between builtin and external util? (e.g. echo)
    – steeldriver
    Aug 8 at 1:16










  • Related: unix.stackexchange.com/q/85249/117549
    – Jeff Schaller
    Aug 8 at 1:17










  • Further to Jeff Schaller's note: observe that in some shells which pushd does not yield nothing, but rather yields pushd: shell built-in command, and the premise of the question is wrong.
    – JdeBP
    Aug 8 at 10:26












up vote
1
down vote

favorite









up vote
1
down vote

favorite











I've been using pushd and popd for a long time while writing bash script. But today when I execute which pushd, I get nothing as output. I can't understand this at all. I was always thinking that pushd is simply a command, just like cd, ls etc.



So why does which pushd give me nothing?










share|improve this question













I've been using pushd and popd for a long time while writing bash script. But today when I execute which pushd, I get nothing as output. I can't understand this at all. I was always thinking that pushd is simply a command, just like cd, ls etc.



So why does which pushd give me nothing?







which pushd






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Aug 8 at 1:12









Yves

809416




809416







  • 1




    Related: How to distinguish between builtin and external util? (e.g. echo)
    – steeldriver
    Aug 8 at 1:16










  • Related: unix.stackexchange.com/q/85249/117549
    – Jeff Schaller
    Aug 8 at 1:17










  • Further to Jeff Schaller's note: observe that in some shells which pushd does not yield nothing, but rather yields pushd: shell built-in command, and the premise of the question is wrong.
    – JdeBP
    Aug 8 at 10:26












  • 1




    Related: How to distinguish between builtin and external util? (e.g. echo)
    – steeldriver
    Aug 8 at 1:16










  • Related: unix.stackexchange.com/q/85249/117549
    – Jeff Schaller
    Aug 8 at 1:17










  • Further to Jeff Schaller's note: observe that in some shells which pushd does not yield nothing, but rather yields pushd: shell built-in command, and the premise of the question is wrong.
    – JdeBP
    Aug 8 at 10:26







1




1




Related: How to distinguish between builtin and external util? (e.g. echo)
– steeldriver
Aug 8 at 1:16




Related: How to distinguish between builtin and external util? (e.g. echo)
– steeldriver
Aug 8 at 1:16












Related: unix.stackexchange.com/q/85249/117549
– Jeff Schaller
Aug 8 at 1:17




Related: unix.stackexchange.com/q/85249/117549
– Jeff Schaller
Aug 8 at 1:17












Further to Jeff Schaller's note: observe that in some shells which pushd does not yield nothing, but rather yields pushd: shell built-in command, and the premise of the question is wrong.
– JdeBP
Aug 8 at 10:26




Further to Jeff Schaller's note: observe that in some shells which pushd does not yield nothing, but rather yields pushd: shell built-in command, and the premise of the question is wrong.
– JdeBP
Aug 8 at 10:26










1 Answer
1






active

oldest

votes

















up vote
3
down vote



accepted










popd and pushd are commands built into Bash, they're not actual executables that live on your HDD as true binaries.



excerpt bash man page

 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.


The full list of all the builtin commands is available in the Bash man page as well as here - http://structure.usc.edu/bash/bashref_4.html.



You can also use compgen -b or enable to get a full list of all these builtins:



compgen

$ compgen -b | grep -E "^push|^pop"
popd
pushd


enable

$ enable -a | grep -E "bpop|bpus"
enable popd
enable pushd


Additionally if you want to get help on the builtins you can use the help command:



$ 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





share|improve this answer






















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f461184%2fwhy-cant-i-which-pushd%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    3
    down vote



    accepted










    popd and pushd are commands built into Bash, they're not actual executables that live on your HDD as true binaries.



    excerpt bash man page

     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.


    The full list of all the builtin commands is available in the Bash man page as well as here - http://structure.usc.edu/bash/bashref_4.html.



    You can also use compgen -b or enable to get a full list of all these builtins:



    compgen

    $ compgen -b | grep -E "^push|^pop"
    popd
    pushd


    enable

    $ enable -a | grep -E "bpop|bpus"
    enable popd
    enable pushd


    Additionally if you want to get help on the builtins you can use the help command:



    $ 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





    share|improve this answer


























      up vote
      3
      down vote



      accepted










      popd and pushd are commands built into Bash, they're not actual executables that live on your HDD as true binaries.



      excerpt bash man page

       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.


      The full list of all the builtin commands is available in the Bash man page as well as here - http://structure.usc.edu/bash/bashref_4.html.



      You can also use compgen -b or enable to get a full list of all these builtins:



      compgen

      $ compgen -b | grep -E "^push|^pop"
      popd
      pushd


      enable

      $ enable -a | grep -E "bpop|bpus"
      enable popd
      enable pushd


      Additionally if you want to get help on the builtins you can use the help command:



      $ 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





      share|improve this answer
























        up vote
        3
        down vote



        accepted







        up vote
        3
        down vote



        accepted






        popd and pushd are commands built into Bash, they're not actual executables that live on your HDD as true binaries.



        excerpt bash man page

         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.


        The full list of all the builtin commands is available in the Bash man page as well as here - http://structure.usc.edu/bash/bashref_4.html.



        You can also use compgen -b or enable to get a full list of all these builtins:



        compgen

        $ compgen -b | grep -E "^push|^pop"
        popd
        pushd


        enable

        $ enable -a | grep -E "bpop|bpus"
        enable popd
        enable pushd


        Additionally if you want to get help on the builtins you can use the help command:



        $ 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





        share|improve this answer














        popd and pushd are commands built into Bash, they're not actual executables that live on your HDD as true binaries.



        excerpt bash man page

         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.


        The full list of all the builtin commands is available in the Bash man page as well as here - http://structure.usc.edu/bash/bashref_4.html.



        You can also use compgen -b or enable to get a full list of all these builtins:



        compgen

        $ compgen -b | grep -E "^push|^pop"
        popd
        pushd


        enable

        $ enable -a | grep -E "bpop|bpus"
        enable popd
        enable pushd


        Additionally if you want to get help on the builtins you can use the help command:



        $ 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






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Aug 8 at 1:40

























        answered Aug 8 at 1:33









        slm♦

        238k65491662




        238k65491662



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f461184%2fwhy-cant-i-which-pushd%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Bahrain

            Postfix configuration issue with fips on centos 7; mailgun relay