mv command is moving to the parent of the provided argument
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
Let's say I have a working directory:
/home/userID/workingDirectory
I type a mv
command that will affect the parent directory of the current working directory and the working directory itself:
mv .* /tmp/someDirectory
When executed, the command moves the content of both directories /home/userID
and /home/userID/workingDirectory
because .*
is a match of the ..
link in the current directory.
So far so good.
But, what I don't understand is why the files and directories are moved to the parent of the argument?
The files appear inside /tmp
instead of /tmp/someDirectory
Can anybody throw some light?
OS is Solaris.
Thanks
command-line directory solaris mv
add a comment |Â
up vote
0
down vote
favorite
Let's say I have a working directory:
/home/userID/workingDirectory
I type a mv
command that will affect the parent directory of the current working directory and the working directory itself:
mv .* /tmp/someDirectory
When executed, the command moves the content of both directories /home/userID
and /home/userID/workingDirectory
because .*
is a match of the ..
link in the current directory.
So far so good.
But, what I don't understand is why the files and directories are moved to the parent of the argument?
The files appear inside /tmp
instead of /tmp/someDirectory
Can anybody throw some light?
OS is Solaris.
Thanks
command-line directory solaris mv
1
Don't have solaris at hand so cannot verify, but you create all structure at the destination, so in particular move content of the parent directory../*
to/tmp/someDirectory/../*
which is/tmp/*
.
â jimmij
Sep 22 at 3:28
Ah, so. Whenmv
goes to the destination path; it's using the argument to recreate the directory structure. And, as the argument to recreate the structure has itself a../*
then it's being interpreted as:/tmp/someDirectory/../*
which will point to/tmp
because is using the..
link inside/tmp/someDirectory
. Am I correct?
â Aeross
Sep 22 at 3:58
1
I'm not sure about that interpretation. Can you verify the expansion of the glob with something likeecho .* /tmp/someDirectory
?
â Sparhawk
Sep 22 at 4:18
I have access to the servers until monday haha... Posted the question here at home because it was bothering me all the way here.
â Aeross
Sep 22 at 4:35
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Let's say I have a working directory:
/home/userID/workingDirectory
I type a mv
command that will affect the parent directory of the current working directory and the working directory itself:
mv .* /tmp/someDirectory
When executed, the command moves the content of both directories /home/userID
and /home/userID/workingDirectory
because .*
is a match of the ..
link in the current directory.
So far so good.
But, what I don't understand is why the files and directories are moved to the parent of the argument?
The files appear inside /tmp
instead of /tmp/someDirectory
Can anybody throw some light?
OS is Solaris.
Thanks
command-line directory solaris mv
Let's say I have a working directory:
/home/userID/workingDirectory
I type a mv
command that will affect the parent directory of the current working directory and the working directory itself:
mv .* /tmp/someDirectory
When executed, the command moves the content of both directories /home/userID
and /home/userID/workingDirectory
because .*
is a match of the ..
link in the current directory.
So far so good.
But, what I don't understand is why the files and directories are moved to the parent of the argument?
The files appear inside /tmp
instead of /tmp/someDirectory
Can anybody throw some light?
OS is Solaris.
Thanks
command-line directory solaris mv
command-line directory solaris mv
asked Sep 22 at 3:14
Aeross
1
1
1
Don't have solaris at hand so cannot verify, but you create all structure at the destination, so in particular move content of the parent directory../*
to/tmp/someDirectory/../*
which is/tmp/*
.
â jimmij
Sep 22 at 3:28
Ah, so. Whenmv
goes to the destination path; it's using the argument to recreate the directory structure. And, as the argument to recreate the structure has itself a../*
then it's being interpreted as:/tmp/someDirectory/../*
which will point to/tmp
because is using the..
link inside/tmp/someDirectory
. Am I correct?
â Aeross
Sep 22 at 3:58
1
I'm not sure about that interpretation. Can you verify the expansion of the glob with something likeecho .* /tmp/someDirectory
?
â Sparhawk
Sep 22 at 4:18
I have access to the servers until monday haha... Posted the question here at home because it was bothering me all the way here.
â Aeross
Sep 22 at 4:35
add a comment |Â
1
Don't have solaris at hand so cannot verify, but you create all structure at the destination, so in particular move content of the parent directory../*
to/tmp/someDirectory/../*
which is/tmp/*
.
â jimmij
Sep 22 at 3:28
Ah, so. Whenmv
goes to the destination path; it's using the argument to recreate the directory structure. And, as the argument to recreate the structure has itself a../*
then it's being interpreted as:/tmp/someDirectory/../*
which will point to/tmp
because is using the..
link inside/tmp/someDirectory
. Am I correct?
â Aeross
Sep 22 at 3:58
1
I'm not sure about that interpretation. Can you verify the expansion of the glob with something likeecho .* /tmp/someDirectory
?
â Sparhawk
Sep 22 at 4:18
I have access to the servers until monday haha... Posted the question here at home because it was bothering me all the way here.
â Aeross
Sep 22 at 4:35
1
1
Don't have solaris at hand so cannot verify, but you create all structure at the destination, so in particular move content of the parent directory
../*
to /tmp/someDirectory/../*
which is /tmp/*
.â jimmij
Sep 22 at 3:28
Don't have solaris at hand so cannot verify, but you create all structure at the destination, so in particular move content of the parent directory
../*
to /tmp/someDirectory/../*
which is /tmp/*
.â jimmij
Sep 22 at 3:28
Ah, so. When
mv
goes to the destination path; it's using the argument to recreate the directory structure. And, as the argument to recreate the structure has itself a ../*
then it's being interpreted as: /tmp/someDirectory/../*
which will point to /tmp
because is using the ..
link inside /tmp/someDirectory
. Am I correct?â Aeross
Sep 22 at 3:58
Ah, so. When
mv
goes to the destination path; it's using the argument to recreate the directory structure. And, as the argument to recreate the structure has itself a ../*
then it's being interpreted as: /tmp/someDirectory/../*
which will point to /tmp
because is using the ..
link inside /tmp/someDirectory
. Am I correct?â Aeross
Sep 22 at 3:58
1
1
I'm not sure about that interpretation. Can you verify the expansion of the glob with something like
echo .* /tmp/someDirectory
?â Sparhawk
Sep 22 at 4:18
I'm not sure about that interpretation. Can you verify the expansion of the glob with something like
echo .* /tmp/someDirectory
?â Sparhawk
Sep 22 at 4:18
I have access to the servers until monday haha... Posted the question here at home because it was bothering me all the way here.
â Aeross
Sep 22 at 4:35
I have access to the servers until monday haha... Posted the question here at home because it was bothering me all the way here.
â Aeross
Sep 22 at 4:35
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
2
down vote
Because basically the system is doing the following when using .*
.
renameat(AT_FDCWD, "../workingDirectory", AT_FDCWD, "/tmp/narf/../workingDirectory") Err#18 EXDEV
Thus it's moved to /tmp/workingDirectory instead of /tmp/narf
To be precise, given that the target is/tmp
, themv
command probably first attempts your postedrenameat()
system call, which likely fails witherrno
set toEXDEV
since/tmp
is almost certainly on a different file system. Themv
command will then copy the file(s), and if successful delete the original(s).
â Andrew Henle
Sep 23 at 22:21
Obviously. Otherwise it wouldn't throw the EXDEV. But it shows the directory string with the ".."
â c0t0d0s0
Sep 24 at 2:47
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
Because basically the system is doing the following when using .*
.
renameat(AT_FDCWD, "../workingDirectory", AT_FDCWD, "/tmp/narf/../workingDirectory") Err#18 EXDEV
Thus it's moved to /tmp/workingDirectory instead of /tmp/narf
To be precise, given that the target is/tmp
, themv
command probably first attempts your postedrenameat()
system call, which likely fails witherrno
set toEXDEV
since/tmp
is almost certainly on a different file system. Themv
command will then copy the file(s), and if successful delete the original(s).
â Andrew Henle
Sep 23 at 22:21
Obviously. Otherwise it wouldn't throw the EXDEV. But it shows the directory string with the ".."
â c0t0d0s0
Sep 24 at 2:47
add a comment |Â
up vote
2
down vote
Because basically the system is doing the following when using .*
.
renameat(AT_FDCWD, "../workingDirectory", AT_FDCWD, "/tmp/narf/../workingDirectory") Err#18 EXDEV
Thus it's moved to /tmp/workingDirectory instead of /tmp/narf
To be precise, given that the target is/tmp
, themv
command probably first attempts your postedrenameat()
system call, which likely fails witherrno
set toEXDEV
since/tmp
is almost certainly on a different file system. Themv
command will then copy the file(s), and if successful delete the original(s).
â Andrew Henle
Sep 23 at 22:21
Obviously. Otherwise it wouldn't throw the EXDEV. But it shows the directory string with the ".."
â c0t0d0s0
Sep 24 at 2:47
add a comment |Â
up vote
2
down vote
up vote
2
down vote
Because basically the system is doing the following when using .*
.
renameat(AT_FDCWD, "../workingDirectory", AT_FDCWD, "/tmp/narf/../workingDirectory") Err#18 EXDEV
Thus it's moved to /tmp/workingDirectory instead of /tmp/narf
Because basically the system is doing the following when using .*
.
renameat(AT_FDCWD, "../workingDirectory", AT_FDCWD, "/tmp/narf/../workingDirectory") Err#18 EXDEV
Thus it's moved to /tmp/workingDirectory instead of /tmp/narf
answered Sep 22 at 21:22
c0t0d0s0
1262
1262
To be precise, given that the target is/tmp
, themv
command probably first attempts your postedrenameat()
system call, which likely fails witherrno
set toEXDEV
since/tmp
is almost certainly on a different file system. Themv
command will then copy the file(s), and if successful delete the original(s).
â Andrew Henle
Sep 23 at 22:21
Obviously. Otherwise it wouldn't throw the EXDEV. But it shows the directory string with the ".."
â c0t0d0s0
Sep 24 at 2:47
add a comment |Â
To be precise, given that the target is/tmp
, themv
command probably first attempts your postedrenameat()
system call, which likely fails witherrno
set toEXDEV
since/tmp
is almost certainly on a different file system. Themv
command will then copy the file(s), and if successful delete the original(s).
â Andrew Henle
Sep 23 at 22:21
Obviously. Otherwise it wouldn't throw the EXDEV. But it shows the directory string with the ".."
â c0t0d0s0
Sep 24 at 2:47
To be precise, given that the target is
/tmp
, the mv
command probably first attempts your posted renameat()
system call, which likely fails with errno
set to EXDEV
since /tmp
is almost certainly on a different file system. The mv
command will then copy the file(s), and if successful delete the original(s).â Andrew Henle
Sep 23 at 22:21
To be precise, given that the target is
/tmp
, the mv
command probably first attempts your posted renameat()
system call, which likely fails with errno
set to EXDEV
since /tmp
is almost certainly on a different file system. The mv
command will then copy the file(s), and if successful delete the original(s).â Andrew Henle
Sep 23 at 22:21
Obviously. Otherwise it wouldn't throw the EXDEV. But it shows the directory string with the ".."
â c0t0d0s0
Sep 24 at 2:47
Obviously. Otherwise it wouldn't throw the EXDEV. But it shows the directory string with the ".."
â c0t0d0s0
Sep 24 at 2:47
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%2f470653%2fmv-command-is-moving-to-the-parent-of-the-provided-argument%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
1
Don't have solaris at hand so cannot verify, but you create all structure at the destination, so in particular move content of the parent directory
../*
to/tmp/someDirectory/../*
which is/tmp/*
.â jimmij
Sep 22 at 3:28
Ah, so. When
mv
goes to the destination path; it's using the argument to recreate the directory structure. And, as the argument to recreate the structure has itself a../*
then it's being interpreted as:/tmp/someDirectory/../*
which will point to/tmp
because is using the..
link inside/tmp/someDirectory
. Am I correct?â Aeross
Sep 22 at 3:58
1
I'm not sure about that interpretation. Can you verify the expansion of the glob with something like
echo .* /tmp/someDirectory
?â Sparhawk
Sep 22 at 4:18
I have access to the servers until monday haha... Posted the question here at home because it was bothering me all the way here.
â Aeross
Sep 22 at 4:35