Created
September 5, 2012 03:50
-
-
Save mikesjewett/3630077 to your computer and use it in GitHub Desktop.
Unix cp example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MICHAELs-MacBook-Pro:rails_projects mike$ pwd | |
#=> this is where I'm starting the example | |
/Users/mike/rails_projects | |
MICHAELs-MacBook-Pro:rails_projects mike$ touch example.txt | |
#=> I'm creating a blank text file called example.txt | |
MICHAELs-MacBook-Pro:rails_projects mike$ mkdir newfolder1 | |
#=> I'm creating a new directory called newfolder1 | |
MICHAELs-MacBook-Pro:rails_projects mike$ cp example.txt newfolder1/ | |
#=> I copy example.txt into newfolder1 | |
MICHAELs-MacBook-Pro:rails_projects mike$ ls newfolder1/ | |
#=> I show the contents of newfolder1 (includes example.txt) | |
example.txt | |
MICHAELs-MacBook-Pro:rails_projects mike$ cp newfolder1 newfolder2 | |
#=> I try to copy the contents of newfolder1 (example.txt) into newfolder2 (which is a new folder that I have not yet created) | |
cp: newfolder1 is a directory (not copied). | |
#=> I get an error telling me the copy didn't work. | |
MICHAELs-MacBook-Pro:rails_projects mike$ cp -r newfolder1 newfolder2 | |
#=> I try to copy again, only this time I use the recurse argument. Recurse ignores the error, and forces the copy (which also creates newfolder2) | |
MICHAELs-MacBook-Pro:rails_projects mike$ ls newfolder2/ | |
#=> I prove that the copy worked by listing the contents of newfolder2. It shows me that it contains example.txt, which is the copied file. | |
example.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment