Skip to main content
Alternative solution
Source Link
Chris Davies
  • 128.2k
  • 16
  • 179
  • 324

You are correct.

If you're using a shell such as bash you can tell it to have * match on dot files as well as usual ones:

shopt -s dotglob
rsync -rt source_dir/* target_dir/

I've added a trailing slash to the target so that it's always considered as a directory - even if the wildcard expands only to a single item. At the other end of the scale, you may encounter problems with the shell enumerating the results if * matches a (very) large number of files.

Possibly a better solution would be use find to generate the set of files, having it exclude the root of the directory tree:

find source_dir -mindepth 1 -print0 |
    rsync -t --files-from=- --from0 . target-dir/

(If source_dir is an absolute path then replace the . with /.)

You are correct.

If you're using a shell such as bash you can tell it to have * match on dot files as well as usual ones:

shopt -s dotglob
rsync -rt source_dir/* target_dir/

I've added a trailing slash to the target so that it's always considered as a directory - even if the wildcard expands only to a single item. At the other end of the scale, you may encounter problems with the shell enumerating the results if * matches a (very) large number of files.

You are correct.

If you're using a shell such as bash you can tell it to have * match on dot files as well as usual ones:

shopt -s dotglob
rsync -rt source_dir/* target_dir/

I've added a trailing slash to the target so that it's always considered as a directory - even if the wildcard expands only to a single item. At the other end of the scale, you may encounter problems with the shell enumerating the results if * matches a (very) large number of files.

Possibly a better solution would be use find to generate the set of files, having it exclude the root of the directory tree:

find source_dir -mindepth 1 -print0 |
    rsync -t --files-from=- --from0 . target-dir/

(If source_dir is an absolute path then replace the . with /.)

added 50 characters in body
Source Link
Chris Davies
  • 128.2k
  • 16
  • 179
  • 324

You are correct.

If you're using a shell such as bash you can tell it to have * match on dot files as well as usual ones:

shopt -s dotglob
rsync -rt source_dir/* target_dir/

I've added a trailing slash to the target so that it's always considered as a directory - even if the wildcard expands only to a single item. At the other end of the scale, you may encounter problemsmay encounter problems with the shell enumerating the results if * matches a (very) large number of files.

You are correct.

If you're using a shell such as bash you can tell it to have * match on dot files as well as usual ones:

shopt -s dotglob
rsync -rt source_dir/* target_dir/

I've added a trailing slash to the target so that it's always considered as a directory - even if the wildcard expands only to a single item. At the other end of the scale, you may encounter problems with the shell enumerating the results if * matches a (very) large number of files.

You are correct.

If you're using a shell such as bash you can tell it to have * match on dot files as well as usual ones:

shopt -s dotglob
rsync -rt source_dir/* target_dir/

I've added a trailing slash to the target so that it's always considered as a directory - even if the wildcard expands only to a single item. At the other end of the scale, you may encounter problems with the shell enumerating the results if * matches a (very) large number of files.

Caution against large wildcard expansions
Source Link
Chris Davies
  • 128.2k
  • 16
  • 179
  • 324

You are correct.

If you're using a shell such as bash you can tell it to have * match on dot files as well as usual ones:

shopt -s dotglob
rsync -rt source_dir/* target_dir/

I've added a trailing slash to the target so that it's always considered as a directory - even if the wildcard expands only to a single item. At the other end of the scale, you may encounter problems with the shell enumerating the results if * matches a (very) large number of files.

You are correct.

If you're using a shell such as bash you can tell it to have * match on dot files as well as usual ones:

shopt -s dotglob
rsync -rt source_dir/* target_dir/

I've added a trailing slash to the target so that it's always considered as a directory - even if the wildcard expands only to a single item

You are correct.

If you're using a shell such as bash you can tell it to have * match on dot files as well as usual ones:

shopt -s dotglob
rsync -rt source_dir/* target_dir/

I've added a trailing slash to the target so that it's always considered as a directory - even if the wildcard expands only to a single item. At the other end of the scale, you may encounter problems with the shell enumerating the results if * matches a (very) large number of files.

Source Link
Chris Davies
  • 128.2k
  • 16
  • 179
  • 324
Loading