How to remove parent directory without deleting sub folders?
Clash 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?
shell rm mv
add a comment |Â
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?
shell rm mv
add a comment |Â
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?
shell rm mv
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
shell rm mv
edited Aug 13 at 10:58
asked Aug 13 at 10:43
EBIN GLADSON
656
656
add a comment |Â
add a comment |Â
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 theparentFolder
)a,b
csh-style brace expansion, also to factorize(/)
: glob qualifier to select only directories. You could also do*/
(which would also work inbash
, but would also include symlinks to directories).(D/)
:D
for dot-files (hidden files whose name starts with.
).
add a comment |Â
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 theparentFolder
)a,b
csh-style brace expansion, also to factorize(/)
: glob qualifier to select only directories. You could also do*/
(which would also work inbash
, but would also include symlinks to directories).(D/)
:D
for dot-files (hidden files whose name starts with.
).
add a comment |Â
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 theparentFolder
)a,b
csh-style brace expansion, also to factorize(/)
: glob qualifier to select only directories. You could also do*/
(which would also work inbash
, but would also include symlinks to directories).(D/)
:D
for dot-files (hidden files whose name starts with.
).
add a comment |Â
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 theparentFolder
)a,b
csh-style brace expansion, also to factorize(/)
: glob qualifier to select only directories. You could also do*/
(which would also work inbash
, but would also include symlinks to directories).(D/)
:D
for dot-files (hidden files whose name starts with.
).
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 theparentFolder
)a,b
csh-style brace expansion, also to factorize(/)
: glob qualifier to select only directories. You could also do*/
(which would also work inbash
, but would also include symlinks to directories).(D/)
:D
for dot-files (hidden files whose name starts with.
).
answered Aug 13 at 10:54
Stéphane Chazelas
284k53524862
284k53524862
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password