Skip to main content
deleted 25 characters in body
Source Link
Chris Davies
  • 128.2k
  • 16
  • 179
  • 324

Your examples don't seem to match your description. I think what you are saying you want is this,

  • match all the *.sh files in an unknown subdirectory immediately underneath your /home/user
  • put the files in the unknown subdirectory on the target
  • do not include /home/user in the destination path

Looking from /home/user, this command will match all files */*.sh and copy them and their partial paths to the target. (Remove the --dry-run if you are happy with the intended result.)

rsync --dry-run -avR /home/user/./*/*.sh /target

For example, /home/user/subdir/file.sh will be copied to /target/subdir/file.sh

Your examples don't seem to match your description. I think what you are saying you want is this,

  • match all the *.sh files in an unknown subdirectory immediately underneath your /home/user
  • put the files in the unknown subdirectory on the target
  • do not include /home/user in the destination path

Looking from /home/user, this command will match all files */*.sh and copy them and their partial paths to the target. (Remove the --dry-run if you are happy with the intended result.)

rsync --dry-run -avR /home/user/./*/*.sh /target

For example, /home/user/subdir/file.sh will be copied to /target/subdir/file.sh

Your examples don't seem to match your description. I think what you are saying you want is this,

  • match all the *.sh files in an unknown subdirectory immediately underneath your /home
  • put the files in the unknown subdirectory on the target
  • do not include /home in the destination path

Looking from /home, this command will match all files */*.sh and copy them and their partial paths to the target. (Remove the --dry-run if you are happy with the intended result.)

rsync --dry-run -avR /home/./*/*.sh /target

For example, /home/subdir/file.sh will be copied to /target/subdir/file.sh

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

Your examples don't seem to match your description. I think what you are saying you want is this,

  • match all the *.sh files in an unknown subdirectory immediately underneath your /home/user
  • put the files in the unknown subdirectory on the target
  • do not include /home/user in the destination path

Looking from /home/user, this command will match all files */*.sh and copy them and their partial paths to the target. (Remove the --dry-run if you are happy with the intended result.)

rsync --dry-run -avR /home/user/./*/*.sh /target

For example, /home/user/subdir/file.sh will be copied to /target/subdir/file.sh