Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bash: scp all files in a directory, but not the subdirectory

Tags:

bash

scp

I would like to copy all files from a remote destination in a particular directory writegrid, but not the subdirectories, e.g. the files in writegrid/output_files.

This

scp -r [email protected]:~/writegrid/* ./

will copy the files in the writegrid/output_files over as well.

Thank you.

like image 630
Cokes Avatar asked Jul 11 '13 18:07

Cokes


People also ask

Can you SCP an entire directory?

To copy a directory (and all the files it contains), use scp with the -r option. This tells scp to recursively copy the source directory and its contents. You'll be prompted for your password on the source system ( deathstar.com ). The command won't work unless you enter the correct password.

How do I copy only the contents of a folder in Linux?

In order to copy a directory on Linux, you have to execute the “cp” command with the “-R” option for recursive and specify the source and destination directories to be copied. As an example, let's say that you want to copy the “/etc” directory into a backup folder named “/etc_backup”.

How do I CP an entire directory?

Copying Directories with cp Command To copy a directory, including all its files and subdirectories, use the -R or -r option.

Can SCP copy directories?

You can use -r option with scp command to copy directories recursively on any system.


1 Answers

Don't use the -r flag. It tells scp to copy recursively.

like image 153
cabad Avatar answered Oct 25 '22 19:10

cabad