How to make scp copy hidden files?
Solution 1:
That should absolutely match hidden files. The / at the end of the source says "every file under this directory". Nevertheless, testing and research bear you out. This is stupid behavior.
The "answer" is to append a dot to the end of the source:
scp -rp src/. user@server:dest/
The real answer is to use rsync.
Solution 2:
You can try rsync. It's better suited for this job:
rsync -av src/ user@server:dest/
(And its manual page is worth reading.)
Solution 3:
Don't put a slash after the source directory. Your code would look like this:
scp -rp src user@server:dest/
This will create a directory 'src' under 'dest' on the remote machine, with all the hidden files included. It's probably not exactly what you want, but it will copy hidden files in src.
Solution 4:
The following will solve the problem, this has been fully tested on our continuous integration environment
scp -rp src/. user@server:dest/
example scp -rp /usr/src/code/. [email protected]:/usr/dest/code/
Hope it helps
Solution 5:
To copy only hidden files, Use this command
scp -rp /path_to_copy_hidden/.[!.]* user@host:/path_to_paste/
Actual game is the /.[!.]*
tag that is referring to files starting with .
(hidden)