How to copy only the files of a folder(including subfolder's files), but not the folder itself in shell
38,019
Solution 1
Try:
scp /path/to/file/* user@server:/path/to/files/
it will complain about not copying directories.
If you want to copy the files in the directories under /path/to/
, you can do:
scp /path/to/*/* user@server:/path/to/files/
Solution 2
Simply use the GLOBIGNORE='*/.:*/..:dirname1:dirname2'
to exclude the specified directories from the *
glob? And then:
scp -r /path/to/file/* user@server:/path/to/files/
Related videos on Youtube
Comments
-
Ricky over 1 year
In Openssh, On the client, the content of path/to/file must be copied to Server. All files in /path/to/file on the client must be copied to /path/to/files on the server. Note: only copy files, no folders! and files of subfolders. please give the command.
-
Ricky over 10 yearsscp –r user@server:/path/to/file/* /path/to/file.. but the result is that desired_folder is not a regular file. and in this folder i want all the files to be copied. but not the desired_folder.
-
Anthon over 10 yearsmaybe you should read the man page for
scp
and not just add random options.-r
means recursively copy entire directories, kind of strange to add that toscp
if that is not what you want. -
Ricky over 10 yearsyes.. thats okey. i had removed that. but still it is not being copied.what about the result that its not a regular file.
-
-
Ricky over 10 yearsbut in above command the folder is also being copied,that is not desired man
-
Ricky over 10 yearsbut i want the files of the directories to be copied.