The rsync program is used for synchronizing files over a network or local disks. To view or display only hidden files with ls command:
ls -ld ~/.??*
ls -ld ~/.[^.]*
rsync not synchronizing all hidden .dot files?
In this example, you used the pattern .[^.]* or .??* to select and display only hidden files using ls command. You can use the same pattern with any Unix command including rsync command. The syntax is as follows to copy hidden files with rsync:
rsync -av /path/to/dir/.??* /path/to/dest rsync -avzP /path/to/dir/.??* /mnt/usb rsync -avzP $HOME/.??* firstname.lastname@example.org:/path/to/backup/users/u/user1 rsync -avzP ~/.[^.]* email@example.com:/path/to/backup/users/u/user1
In this example, copy all hidden files from my home directory to /mnt/test:
rsync -avzP ~/.[^.]* /mnt/test
Rsync Copy Hidden Dot File Command Options
The options are as follows:
- -a – Archive mode copy. In this mode all given files are copied in recursive mode. Copy symlinks as symlinks, file permissions, date and time stapms, and much more.
- -v – Verbose copy. In other words, show what the rsync is doing.
- -z – Compress file data during the transfer.
- -P – Display progress bar
You learned how to to use the rsync command to copy hidden dot files including directories. See rsync man page here for more info or type the following man command: