How to Copy Files in Mac Terminal
Copying Files in Mac Terminal
To copy files, use the cp command. This command allows you to copy files from one location to another.
Steps to Copy Files
- Step 1: Open Terminal.
- Step 2: Type
cp [source] [destination]to copy a file. For example, to copymyfile.txtfrom your home directory to Documents:cp ~/myfile.txt ~/Documents/ - Step 3: To copy a directory and its contents, use the
-roption (recursive):
This copies all files and subdirectories inside the source directory to the destination.cp -r [source_directory] [destination]
Understanding the Output
The cp command does not return any output if it is successful. You can use the ls command to verify that the file was copied correctly.
Conclusion
The cp command is a quick way to copy files and directories. Use the -r option for directories and the ls command to check the result.