Networking – Copying Files from Remote Device Without Creating an Archive

command linenetworkingscp

Normally, if I wanted to copy files from a remote machine I would do

scp user@remote.device:/folder/* .

However, in this case there are so many files that get I the error

bash: /usr/bin/scp: Argument list too long

Now, from googling this problem I can find several ways to create a tar archive on the remote machine without triggering this error. However, in this case the remote machine only has a small SD card for storage so there is no space to create an archive.

So what would be the normal way to transfer the files in this case? I guess it shouldn't make much difference, but in case it does, my local machine is a Mac and the remote one is a Raspberry Pi.

Best Answer

You should use the -r parameter of scp, so:

scp -r user@remote.device:/folder/ ./

Note that as a result, folder will end up as a sub-folder of ./

Related Question