scp
is a command for sending files over SSH. This means you can copy files between computers, say from your Raspberry Pi to your desktop or laptop, or vice-versa.
First of all, you'll need to know your Raspberry Pi's IP address.
Copy the file myfile.txt
from your computer to the pi
user's home folder of your Raspberry Pi at the IP address 192.168.1.3
with the following command:
scp myfile.txt pi@192.168.1.3:
Copy the file to the /home/pi/project/
directory on your Raspberry Pi (the project
folder must already exist):
scp myfile.txt pi@192.168.1.3:project/
Copy the file myfile.txt
from your Raspberry Pi to the current directory on your other computer:
scp pi@192.168.1.3:myfile.txt .
Copy multiple files by separating them with spaces:
scp myfile.txt myfile2.txt pi@192.168.1.3:
Alternatively, use a wildcard to copy all files matching a particular search with:
scp *.txt pi@192.168.1.3:
(all files ending in .txt
)
scp m* pi@192.168.1.3:
(all files starting with m
)
scp m*.txt pi@192.168.1.3:
(all files starting with m
and ending in .txt
)
Note that some of the examples above will not work for file names containing spaces. Names like this need to be encased in quotes:
scp "my file.txt" pi@192.168.1.3: