How to remove parent directory without deleting sub folders?

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











up vote
0
down vote

favorite












For Example,



I have 5 directories inside parent directory, I want to delete parent directory without deleting 5 subdirectories.



As of now am doing with below code,



 mv parentFolder/* parentFolder/.. && rm -rf parentFolder


Do we have any other simpler option than this?










share|improve this question



























    up vote
    0
    down vote

    favorite












    For Example,



    I have 5 directories inside parent directory, I want to delete parent directory without deleting 5 subdirectories.



    As of now am doing with below code,



     mv parentFolder/* parentFolder/.. && rm -rf parentFolder


    Do we have any other simpler option than this?










    share|improve this question

























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      For Example,



      I have 5 directories inside parent directory, I want to delete parent directory without deleting 5 subdirectories.



      As of now am doing with below code,



       mv parentFolder/* parentFolder/.. && rm -rf parentFolder


      Do we have any other simpler option than this?










      share|improve this question















      For Example,



      I have 5 directories inside parent directory, I want to delete parent directory without deleting 5 subdirectories.



      As of now am doing with below code,



       mv parentFolder/* parentFolder/.. && rm -rf parentFolder


      Do we have any other simpler option than this?







      shell rm mv






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Aug 13 at 10:58

























      asked Aug 13 at 10:43









      EBIN GLADSON

      656




      656




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          1
          down vote













          mv parentFolder/* parentFolder/..


          Would move all the (non-hidden) files, not only those of type directory.



          To move only the directories, with zsh (also shortening the code)



          ()mv $1/*(/),.. && rm -rf $1 parentFolder


          Or to include hidden ones:



          ()mv $1/*(D/),.. && rm -rf $1 parentFolder



          • ()..$1.. arg: anonymous function with an argument (to factorise the parentFolder)


          • a,b csh-style brace expansion, also to factorize


          • (/): glob qualifier to select only directories. You could also do */ (which would also work in bash, but would also include symlinks to directories).


          • (D/): D for dot-files (hidden files whose name starts with .).





          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%2f462271%2fhow-to-remove-parent-directory-without-deleting-sub-folders%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
            1
            down vote













            mv parentFolder/* parentFolder/..


            Would move all the (non-hidden) files, not only those of type directory.



            To move only the directories, with zsh (also shortening the code)



            ()mv $1/*(/),.. && rm -rf $1 parentFolder


            Or to include hidden ones:



            ()mv $1/*(D/),.. && rm -rf $1 parentFolder



            • ()..$1.. arg: anonymous function with an argument (to factorise the parentFolder)


            • a,b csh-style brace expansion, also to factorize


            • (/): glob qualifier to select only directories. You could also do */ (which would also work in bash, but would also include symlinks to directories).


            • (D/): D for dot-files (hidden files whose name starts with .).





            share|improve this answer
























              up vote
              1
              down vote













              mv parentFolder/* parentFolder/..


              Would move all the (non-hidden) files, not only those of type directory.



              To move only the directories, with zsh (also shortening the code)



              ()mv $1/*(/),.. && rm -rf $1 parentFolder


              Or to include hidden ones:



              ()mv $1/*(D/),.. && rm -rf $1 parentFolder



              • ()..$1.. arg: anonymous function with an argument (to factorise the parentFolder)


              • a,b csh-style brace expansion, also to factorize


              • (/): glob qualifier to select only directories. You could also do */ (which would also work in bash, but would also include symlinks to directories).


              • (D/): D for dot-files (hidden files whose name starts with .).





              share|improve this answer






















                up vote
                1
                down vote










                up vote
                1
                down vote









                mv parentFolder/* parentFolder/..


                Would move all the (non-hidden) files, not only those of type directory.



                To move only the directories, with zsh (also shortening the code)



                ()mv $1/*(/),.. && rm -rf $1 parentFolder


                Or to include hidden ones:



                ()mv $1/*(D/),.. && rm -rf $1 parentFolder



                • ()..$1.. arg: anonymous function with an argument (to factorise the parentFolder)


                • a,b csh-style brace expansion, also to factorize


                • (/): glob qualifier to select only directories. You could also do */ (which would also work in bash, but would also include symlinks to directories).


                • (D/): D for dot-files (hidden files whose name starts with .).





                share|improve this answer












                mv parentFolder/* parentFolder/..


                Would move all the (non-hidden) files, not only those of type directory.



                To move only the directories, with zsh (also shortening the code)



                ()mv $1/*(/),.. && rm -rf $1 parentFolder


                Or to include hidden ones:



                ()mv $1/*(D/),.. && rm -rf $1 parentFolder



                • ()..$1.. arg: anonymous function with an argument (to factorise the parentFolder)


                • a,b csh-style brace expansion, also to factorize


                • (/): glob qualifier to select only directories. You could also do */ (which would also work in bash, but would also include symlinks to directories).


                • (D/): D for dot-files (hidden files whose name starts with .).






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Aug 13 at 10:54









                Stéphane Chazelas

                284k53524862




                284k53524862



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f462271%2fhow-to-remove-parent-directory-without-deleting-sub-folders%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