Is there a way to create a directory and access it in a single command chain?












0















I wanted to create a directory and access it after creation in a single command chain using:



mkdir directory_name && cd directory_name



is there a better way to do it that is built-in in linux without the need of creating a function to achieve that?



to be able to make a directory and access it without repeating the directory name?










share|improve this question




















  • 2





    Possible duplicate of How can I make my own "shell commands" (e.g. mkdir/cd combo)?

    – Kamil Maciorowski
    Jan 31 at 15:16











  • I didn't mean asking for a function to do it, what I meant was if there is something built-in in linux that can achieve that.

    – Mrwan Ashraf
    Jan 31 at 15:18











  • On UNIX (Linux) you have many small tools that do one thing well. It is normal to combine these tools for more complex tasks, so what's the reason against using a function or script?

    – Bodo
    Jan 31 at 15:33











  • @Bodo i could have made the script already without asking but i didn't want to reinvent the wheel so i wanted to make sure first if the solution I'm looking for exists, more like a terminal tip.

    – Mrwan Ashraf
    Jan 31 at 15:37
















0















I wanted to create a directory and access it after creation in a single command chain using:



mkdir directory_name && cd directory_name



is there a better way to do it that is built-in in linux without the need of creating a function to achieve that?



to be able to make a directory and access it without repeating the directory name?










share|improve this question




















  • 2





    Possible duplicate of How can I make my own "shell commands" (e.g. mkdir/cd combo)?

    – Kamil Maciorowski
    Jan 31 at 15:16











  • I didn't mean asking for a function to do it, what I meant was if there is something built-in in linux that can achieve that.

    – Mrwan Ashraf
    Jan 31 at 15:18











  • On UNIX (Linux) you have many small tools that do one thing well. It is normal to combine these tools for more complex tasks, so what's the reason against using a function or script?

    – Bodo
    Jan 31 at 15:33











  • @Bodo i could have made the script already without asking but i didn't want to reinvent the wheel so i wanted to make sure first if the solution I'm looking for exists, more like a terminal tip.

    – Mrwan Ashraf
    Jan 31 at 15:37














0












0








0


1






I wanted to create a directory and access it after creation in a single command chain using:



mkdir directory_name && cd directory_name



is there a better way to do it that is built-in in linux without the need of creating a function to achieve that?



to be able to make a directory and access it without repeating the directory name?










share|improve this question
















I wanted to create a directory and access it after creation in a single command chain using:



mkdir directory_name && cd directory_name



is there a better way to do it that is built-in in linux without the need of creating a function to achieve that?



to be able to make a directory and access it without repeating the directory name?







linux bash






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 31 at 15:22







Mrwan Ashraf

















asked Jan 31 at 15:14









Mrwan AshrafMrwan Ashraf

13




13








  • 2





    Possible duplicate of How can I make my own "shell commands" (e.g. mkdir/cd combo)?

    – Kamil Maciorowski
    Jan 31 at 15:16











  • I didn't mean asking for a function to do it, what I meant was if there is something built-in in linux that can achieve that.

    – Mrwan Ashraf
    Jan 31 at 15:18











  • On UNIX (Linux) you have many small tools that do one thing well. It is normal to combine these tools for more complex tasks, so what's the reason against using a function or script?

    – Bodo
    Jan 31 at 15:33











  • @Bodo i could have made the script already without asking but i didn't want to reinvent the wheel so i wanted to make sure first if the solution I'm looking for exists, more like a terminal tip.

    – Mrwan Ashraf
    Jan 31 at 15:37














  • 2





    Possible duplicate of How can I make my own "shell commands" (e.g. mkdir/cd combo)?

    – Kamil Maciorowski
    Jan 31 at 15:16











  • I didn't mean asking for a function to do it, what I meant was if there is something built-in in linux that can achieve that.

    – Mrwan Ashraf
    Jan 31 at 15:18











  • On UNIX (Linux) you have many small tools that do one thing well. It is normal to combine these tools for more complex tasks, so what's the reason against using a function or script?

    – Bodo
    Jan 31 at 15:33











  • @Bodo i could have made the script already without asking but i didn't want to reinvent the wheel so i wanted to make sure first if the solution I'm looking for exists, more like a terminal tip.

    – Mrwan Ashraf
    Jan 31 at 15:37








2




2





Possible duplicate of How can I make my own "shell commands" (e.g. mkdir/cd combo)?

– Kamil Maciorowski
Jan 31 at 15:16





Possible duplicate of How can I make my own "shell commands" (e.g. mkdir/cd combo)?

– Kamil Maciorowski
Jan 31 at 15:16













I didn't mean asking for a function to do it, what I meant was if there is something built-in in linux that can achieve that.

– Mrwan Ashraf
Jan 31 at 15:18





I didn't mean asking for a function to do it, what I meant was if there is something built-in in linux that can achieve that.

– Mrwan Ashraf
Jan 31 at 15:18













On UNIX (Linux) you have many small tools that do one thing well. It is normal to combine these tools for more complex tasks, so what's the reason against using a function or script?

– Bodo
Jan 31 at 15:33





On UNIX (Linux) you have many small tools that do one thing well. It is normal to combine these tools for more complex tasks, so what's the reason against using a function or script?

– Bodo
Jan 31 at 15:33













@Bodo i could have made the script already without asking but i didn't want to reinvent the wheel so i wanted to make sure first if the solution I'm looking for exists, more like a terminal tip.

– Mrwan Ashraf
Jan 31 at 15:37





@Bodo i could have made the script already without asking but i didn't want to reinvent the wheel so i wanted to make sure first if the solution I'm looking for exists, more like a terminal tip.

– Mrwan Ashraf
Jan 31 at 15:37










1 Answer
1






active

oldest

votes


















0














here is how to do it based on the answer i have found:



mkdir directory_name && cd "$_"






share|improve this answer























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "3"
    };
    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',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1400621%2fis-there-a-way-to-create-a-directory-and-access-it-in-a-single-command-chain%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    here is how to do it based on the answer i have found:



    mkdir directory_name && cd "$_"






    share|improve this answer




























      0














      here is how to do it based on the answer i have found:



      mkdir directory_name && cd "$_"






      share|improve this answer


























        0












        0








        0







        here is how to do it based on the answer i have found:



        mkdir directory_name && cd "$_"






        share|improve this answer













        here is how to do it based on the answer i have found:



        mkdir directory_name && cd "$_"







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 31 at 15:45









        Mrwan AshrafMrwan Ashraf

        13




        13






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Super User!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1400621%2fis-there-a-way-to-create-a-directory-and-access-it-in-a-single-command-chain%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Terni

            A new problem with tex4ht and tikz

            Sun Ra