include dot files (.x) with rsync -r command
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
I have the following command:
rsync -r --exclude="node_modules" "/r2g_shared_dir/vamoot"/* "/home/node/.docker_r2g_cache/b640e7fd-27a7-4dd8-8ca8-5363a1c59c35"
I just realized that using /* will not copy over dot files (files/folders that start with .)...
Anybody know how I can include those files?
I assume the best way would be to forgo the /* notation and just use
rsync -r --exclude="node_modules" "/r2g_shared_dir/vamoot" "/home/node/.docker_r2g_cache/b640e7fd-27a7-4dd8-8ca8-5363a1c59c35"
but is there another way?
bash shell-script rsync wildcards
add a comment |Â
up vote
1
down vote
favorite
I have the following command:
rsync -r --exclude="node_modules" "/r2g_shared_dir/vamoot"/* "/home/node/.docker_r2g_cache/b640e7fd-27a7-4dd8-8ca8-5363a1c59c35"
I just realized that using /* will not copy over dot files (files/folders that start with .)...
Anybody know how I can include those files?
I assume the best way would be to forgo the /* notation and just use
rsync -r --exclude="node_modules" "/r2g_shared_dir/vamoot" "/home/node/.docker_r2g_cache/b640e7fd-27a7-4dd8-8ca8-5363a1c59c35"
but is there another way?
bash shell-script rsync wildcards
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I have the following command:
rsync -r --exclude="node_modules" "/r2g_shared_dir/vamoot"/* "/home/node/.docker_r2g_cache/b640e7fd-27a7-4dd8-8ca8-5363a1c59c35"
I just realized that using /* will not copy over dot files (files/folders that start with .)...
Anybody know how I can include those files?
I assume the best way would be to forgo the /* notation and just use
rsync -r --exclude="node_modules" "/r2g_shared_dir/vamoot" "/home/node/.docker_r2g_cache/b640e7fd-27a7-4dd8-8ca8-5363a1c59c35"
but is there another way?
bash shell-script rsync wildcards
I have the following command:
rsync -r --exclude="node_modules" "/r2g_shared_dir/vamoot"/* "/home/node/.docker_r2g_cache/b640e7fd-27a7-4dd8-8ca8-5363a1c59c35"
I just realized that using /* will not copy over dot files (files/folders that start with .)...
Anybody know how I can include those files?
I assume the best way would be to forgo the /* notation and just use
rsync -r --exclude="node_modules" "/r2g_shared_dir/vamoot" "/home/node/.docker_r2g_cache/b640e7fd-27a7-4dd8-8ca8-5363a1c59c35"
but is there another way?
bash shell-script rsync wildcards
asked May 27 at 20:51
Alexander Mills
1,878929
1,878929
add a comment |Â
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
1
down vote
accepted
If this is bash you can just set dotglob
:
shopt -s dotglob
This does not match .
or ..
(in contrast to .*
).
So the same command could be used:
rsync -r --exclude="node_modules" "/r2g_shared_dir/vamoot"/* ...
So I would do:rsync -r "/r2g_shared_dir/vamoot"/.*
??
â Alexander Mills
May 27 at 21:09
@AlexanderMills No, see the edit. Sorry, I thought that was obvious.
â Hauke Laging
May 27 at 21:24
ah sorry now I get it
â Alexander Mills
May 27 at 21:25
1
It would be better to simply leave out the*
in the rsync command, but include the slash, otherwise thevamoot
directory is also trasferred in the path:rsync -r "/r2g_shared_dir/vamoot"/ ....
â wurtel
May 28 at 14:48
@wurtel It might be more useful to make that an answer.
â Hauke Laging
May 28 at 17:21
add a comment |Â
up vote
0
down vote
It's best to leave the pattern matching to rsync, then you're not depending on whatever shell and options that shell has at that time.
When you do:
rsync -a /some/dir/* host:/remote/dir/
then you're actually asking the shell to expand the /some/dir/*
part, so that rsync is actually executed like this:
rsync -a /some/dir/adir /some/dir/afile /some/dir/anotherfile [etc] host:/remote/dir/
This is usually quite similar to what the intention was, however not always as demonstrated by the fact that this question was asked. Hence it's better to execute:
rsync -a /some/dir/ host:/remote/dir/
Now rsync will (because -a
is shorthand for -rlptgoD
which includes -r
for recursion) recursively walk through the /some/dir
directory and sync all its contents to /remote/dir
on the remote host, including any dot files directly in /some/dir
.
As the source path ends with a slash /
, the filenames transferred omit any part of the source location. If /some/dir
was passed, then you're telling to explicitly sync the dir
directory, including its name. It's recommended to get into the habit of adding the last slash at all times to avoid such confusion, unless you really understand what's going on.
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
If this is bash you can just set dotglob
:
shopt -s dotglob
This does not match .
or ..
(in contrast to .*
).
So the same command could be used:
rsync -r --exclude="node_modules" "/r2g_shared_dir/vamoot"/* ...
So I would do:rsync -r "/r2g_shared_dir/vamoot"/.*
??
â Alexander Mills
May 27 at 21:09
@AlexanderMills No, see the edit. Sorry, I thought that was obvious.
â Hauke Laging
May 27 at 21:24
ah sorry now I get it
â Alexander Mills
May 27 at 21:25
1
It would be better to simply leave out the*
in the rsync command, but include the slash, otherwise thevamoot
directory is also trasferred in the path:rsync -r "/r2g_shared_dir/vamoot"/ ....
â wurtel
May 28 at 14:48
@wurtel It might be more useful to make that an answer.
â Hauke Laging
May 28 at 17:21
add a comment |Â
up vote
1
down vote
accepted
If this is bash you can just set dotglob
:
shopt -s dotglob
This does not match .
or ..
(in contrast to .*
).
So the same command could be used:
rsync -r --exclude="node_modules" "/r2g_shared_dir/vamoot"/* ...
So I would do:rsync -r "/r2g_shared_dir/vamoot"/.*
??
â Alexander Mills
May 27 at 21:09
@AlexanderMills No, see the edit. Sorry, I thought that was obvious.
â Hauke Laging
May 27 at 21:24
ah sorry now I get it
â Alexander Mills
May 27 at 21:25
1
It would be better to simply leave out the*
in the rsync command, but include the slash, otherwise thevamoot
directory is also trasferred in the path:rsync -r "/r2g_shared_dir/vamoot"/ ....
â wurtel
May 28 at 14:48
@wurtel It might be more useful to make that an answer.
â Hauke Laging
May 28 at 17:21
add a comment |Â
up vote
1
down vote
accepted
up vote
1
down vote
accepted
If this is bash you can just set dotglob
:
shopt -s dotglob
This does not match .
or ..
(in contrast to .*
).
So the same command could be used:
rsync -r --exclude="node_modules" "/r2g_shared_dir/vamoot"/* ...
If this is bash you can just set dotglob
:
shopt -s dotglob
This does not match .
or ..
(in contrast to .*
).
So the same command could be used:
rsync -r --exclude="node_modules" "/r2g_shared_dir/vamoot"/* ...
edited May 27 at 21:23
answered May 27 at 21:06
Hauke Laging
53.1k1282130
53.1k1282130
So I would do:rsync -r "/r2g_shared_dir/vamoot"/.*
??
â Alexander Mills
May 27 at 21:09
@AlexanderMills No, see the edit. Sorry, I thought that was obvious.
â Hauke Laging
May 27 at 21:24
ah sorry now I get it
â Alexander Mills
May 27 at 21:25
1
It would be better to simply leave out the*
in the rsync command, but include the slash, otherwise thevamoot
directory is also trasferred in the path:rsync -r "/r2g_shared_dir/vamoot"/ ....
â wurtel
May 28 at 14:48
@wurtel It might be more useful to make that an answer.
â Hauke Laging
May 28 at 17:21
add a comment |Â
So I would do:rsync -r "/r2g_shared_dir/vamoot"/.*
??
â Alexander Mills
May 27 at 21:09
@AlexanderMills No, see the edit. Sorry, I thought that was obvious.
â Hauke Laging
May 27 at 21:24
ah sorry now I get it
â Alexander Mills
May 27 at 21:25
1
It would be better to simply leave out the*
in the rsync command, but include the slash, otherwise thevamoot
directory is also trasferred in the path:rsync -r "/r2g_shared_dir/vamoot"/ ....
â wurtel
May 28 at 14:48
@wurtel It might be more useful to make that an answer.
â Hauke Laging
May 28 at 17:21
So I would do:
rsync -r "/r2g_shared_dir/vamoot"/.*
??â Alexander Mills
May 27 at 21:09
So I would do:
rsync -r "/r2g_shared_dir/vamoot"/.*
??â Alexander Mills
May 27 at 21:09
@AlexanderMills No, see the edit. Sorry, I thought that was obvious.
â Hauke Laging
May 27 at 21:24
@AlexanderMills No, see the edit. Sorry, I thought that was obvious.
â Hauke Laging
May 27 at 21:24
ah sorry now I get it
â Alexander Mills
May 27 at 21:25
ah sorry now I get it
â Alexander Mills
May 27 at 21:25
1
1
It would be better to simply leave out the
*
in the rsync command, but include the slash, otherwise the vamoot
directory is also trasferred in the path: rsync -r "/r2g_shared_dir/vamoot"/ ....
â wurtel
May 28 at 14:48
It would be better to simply leave out the
*
in the rsync command, but include the slash, otherwise the vamoot
directory is also trasferred in the path: rsync -r "/r2g_shared_dir/vamoot"/ ....
â wurtel
May 28 at 14:48
@wurtel It might be more useful to make that an answer.
â Hauke Laging
May 28 at 17:21
@wurtel It might be more useful to make that an answer.
â Hauke Laging
May 28 at 17:21
add a comment |Â
up vote
0
down vote
It's best to leave the pattern matching to rsync, then you're not depending on whatever shell and options that shell has at that time.
When you do:
rsync -a /some/dir/* host:/remote/dir/
then you're actually asking the shell to expand the /some/dir/*
part, so that rsync is actually executed like this:
rsync -a /some/dir/adir /some/dir/afile /some/dir/anotherfile [etc] host:/remote/dir/
This is usually quite similar to what the intention was, however not always as demonstrated by the fact that this question was asked. Hence it's better to execute:
rsync -a /some/dir/ host:/remote/dir/
Now rsync will (because -a
is shorthand for -rlptgoD
which includes -r
for recursion) recursively walk through the /some/dir
directory and sync all its contents to /remote/dir
on the remote host, including any dot files directly in /some/dir
.
As the source path ends with a slash /
, the filenames transferred omit any part of the source location. If /some/dir
was passed, then you're telling to explicitly sync the dir
directory, including its name. It's recommended to get into the habit of adding the last slash at all times to avoid such confusion, unless you really understand what's going on.
add a comment |Â
up vote
0
down vote
It's best to leave the pattern matching to rsync, then you're not depending on whatever shell and options that shell has at that time.
When you do:
rsync -a /some/dir/* host:/remote/dir/
then you're actually asking the shell to expand the /some/dir/*
part, so that rsync is actually executed like this:
rsync -a /some/dir/adir /some/dir/afile /some/dir/anotherfile [etc] host:/remote/dir/
This is usually quite similar to what the intention was, however not always as demonstrated by the fact that this question was asked. Hence it's better to execute:
rsync -a /some/dir/ host:/remote/dir/
Now rsync will (because -a
is shorthand for -rlptgoD
which includes -r
for recursion) recursively walk through the /some/dir
directory and sync all its contents to /remote/dir
on the remote host, including any dot files directly in /some/dir
.
As the source path ends with a slash /
, the filenames transferred omit any part of the source location. If /some/dir
was passed, then you're telling to explicitly sync the dir
directory, including its name. It's recommended to get into the habit of adding the last slash at all times to avoid such confusion, unless you really understand what's going on.
add a comment |Â
up vote
0
down vote
up vote
0
down vote
It's best to leave the pattern matching to rsync, then you're not depending on whatever shell and options that shell has at that time.
When you do:
rsync -a /some/dir/* host:/remote/dir/
then you're actually asking the shell to expand the /some/dir/*
part, so that rsync is actually executed like this:
rsync -a /some/dir/adir /some/dir/afile /some/dir/anotherfile [etc] host:/remote/dir/
This is usually quite similar to what the intention was, however not always as demonstrated by the fact that this question was asked. Hence it's better to execute:
rsync -a /some/dir/ host:/remote/dir/
Now rsync will (because -a
is shorthand for -rlptgoD
which includes -r
for recursion) recursively walk through the /some/dir
directory and sync all its contents to /remote/dir
on the remote host, including any dot files directly in /some/dir
.
As the source path ends with a slash /
, the filenames transferred omit any part of the source location. If /some/dir
was passed, then you're telling to explicitly sync the dir
directory, including its name. It's recommended to get into the habit of adding the last slash at all times to avoid such confusion, unless you really understand what's going on.
It's best to leave the pattern matching to rsync, then you're not depending on whatever shell and options that shell has at that time.
When you do:
rsync -a /some/dir/* host:/remote/dir/
then you're actually asking the shell to expand the /some/dir/*
part, so that rsync is actually executed like this:
rsync -a /some/dir/adir /some/dir/afile /some/dir/anotherfile [etc] host:/remote/dir/
This is usually quite similar to what the intention was, however not always as demonstrated by the fact that this question was asked. Hence it's better to execute:
rsync -a /some/dir/ host:/remote/dir/
Now rsync will (because -a
is shorthand for -rlptgoD
which includes -r
for recursion) recursively walk through the /some/dir
directory and sync all its contents to /remote/dir
on the remote host, including any dot files directly in /some/dir
.
As the source path ends with a slash /
, the filenames transferred omit any part of the source location. If /some/dir
was passed, then you're telling to explicitly sync the dir
directory, including its name. It's recommended to get into the habit of adding the last slash at all times to avoid such confusion, unless you really understand what's going on.
answered May 29 at 10:25
wurtel
8,7151822
8,7151822
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%2f446348%2finclude-dot-files-x-with-rsync-r-command%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