How do I replace a folder with its only subfolder of the same name in CLI?
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
Suppose that I have only the following in ~/foo
:
.
..
foo
With file managers if I cut the subfolder foo
and paste it into ~
it automatically replaces the contents of ~/foo
with that of ~/foo/foo
.
But is there a native command-line tool to do so, although I can achieve the goal with a function, too?
shell command-line files move
add a comment |Â
up vote
1
down vote
favorite
Suppose that I have only the following in ~/foo
:
.
..
foo
With file managers if I cut the subfolder foo
and paste it into ~
it automatically replaces the contents of ~/foo
with that of ~/foo/foo
.
But is there a native command-line tool to do so, although I can achieve the goal with a function, too?
shell command-line files move
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
Suppose that I have only the following in ~/foo
:
.
..
foo
With file managers if I cut the subfolder foo
and paste it into ~
it automatically replaces the contents of ~/foo
with that of ~/foo/foo
.
But is there a native command-line tool to do so, although I can achieve the goal with a function, too?
shell command-line files move
Suppose that I have only the following in ~/foo
:
.
..
foo
With file managers if I cut the subfolder foo
and paste it into ~
it automatically replaces the contents of ~/foo
with that of ~/foo/foo
.
But is there a native command-line tool to do so, although I can achieve the goal with a function, too?
shell command-line files move
edited Apr 29 at 3:48
G-Man
11.5k82656
11.5k82656
asked Apr 29 at 2:55
cvoret
82
82
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
I donâÂÂt know any way to do it in one step,
but the easiest way around the problem is to remove the problem.ÃÂ
The fact that the two directories have the same name is a problem;
so, rename one of them:
mv foo foo2 && mv foo2/foo foo && rmdir foo2
1
Or with GNUmv
:mv -iT foo/foo foo2 && mv -T foo2 foo
. One question would be: whichfoo
would we like to preserve the metadata of?
â Stéphane Chazelas
Apr 29 at 6:43
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
accepted
I donâÂÂt know any way to do it in one step,
but the easiest way around the problem is to remove the problem.ÃÂ
The fact that the two directories have the same name is a problem;
so, rename one of them:
mv foo foo2 && mv foo2/foo foo && rmdir foo2
1
Or with GNUmv
:mv -iT foo/foo foo2 && mv -T foo2 foo
. One question would be: whichfoo
would we like to preserve the metadata of?
â Stéphane Chazelas
Apr 29 at 6:43
add a comment |Â
up vote
1
down vote
accepted
I donâÂÂt know any way to do it in one step,
but the easiest way around the problem is to remove the problem.ÃÂ
The fact that the two directories have the same name is a problem;
so, rename one of them:
mv foo foo2 && mv foo2/foo foo && rmdir foo2
1
Or with GNUmv
:mv -iT foo/foo foo2 && mv -T foo2 foo
. One question would be: whichfoo
would we like to preserve the metadata of?
â Stéphane Chazelas
Apr 29 at 6:43
add a comment |Â
up vote
1
down vote
accepted
up vote
1
down vote
accepted
I donâÂÂt know any way to do it in one step,
but the easiest way around the problem is to remove the problem.ÃÂ
The fact that the two directories have the same name is a problem;
so, rename one of them:
mv foo foo2 && mv foo2/foo foo && rmdir foo2
I donâÂÂt know any way to do it in one step,
but the easiest way around the problem is to remove the problem.ÃÂ
The fact that the two directories have the same name is a problem;
so, rename one of them:
mv foo foo2 && mv foo2/foo foo && rmdir foo2
edited Apr 29 at 4:32
answered Apr 29 at 3:54
G-Man
11.5k82656
11.5k82656
1
Or with GNUmv
:mv -iT foo/foo foo2 && mv -T foo2 foo
. One question would be: whichfoo
would we like to preserve the metadata of?
â Stéphane Chazelas
Apr 29 at 6:43
add a comment |Â
1
Or with GNUmv
:mv -iT foo/foo foo2 && mv -T foo2 foo
. One question would be: whichfoo
would we like to preserve the metadata of?
â Stéphane Chazelas
Apr 29 at 6:43
1
1
Or with GNU
mv
: mv -iT foo/foo foo2 && mv -T foo2 foo
. One question would be: which foo
would we like to preserve the metadata of?â Stéphane Chazelas
Apr 29 at 6:43
Or with GNU
mv
: mv -iT foo/foo foo2 && mv -T foo2 foo
. One question would be: which foo
would we like to preserve the metadata of?â Stéphane Chazelas
Apr 29 at 6:43
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%2f440668%2fhow-do-i-replace-a-folder-with-its-only-subfolder-of-the-same-name-in-cli%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