Want to highlight a helpful answer? Upvote!

Did someone help you, or did an answer or User Tip resolve your issue? Upvote by selecting the upvote arrow. Your feedback helps others! Learn more about when to upvote >

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Copy/replace an Application via Terminal

I was wondering what the correct arguments are for copying an App from a location to the /Applications folder. .app files appear to be different than other files in the sense that they are seen in Terminal as "folders" and Terminal doesn't seem to like that very much.


2 questions here:


If I were to copy an app from one location (say, Downloads) to my /Applications folder, what would the correct Terminal cp syntax be?


If there were an older version of the application, what would I need to add in to tell Terminal to replace the existing App?

Posted on Nov 1, 2011 6:53 AM

Reply
11 replies

Nov 1, 2011 6:58 AM in response to evets90

I am not at home right now to check the syntax Mac OS X wants to see, but you can do a simple man cp in terminal and you will get the options list. It should be something of the form <cp -R .Downloads/folder name ./Applications> The -R does a recursive copy of the folder and all contents. Check the exact syntax, however, by doing the man search.

Nov 1, 2011 7:14 AM in response to evets90

Somewhere in the list of options there should be recursive switch, most Unix systems use -R but some may use a -r, the trick is to be using the right one. You can always make sure the -i switch is set so it asks you for permissiont to do copy on each file in the directory...kind of painful if there are a lot of files.


Ok, Berkely 4.3, Mac OS X is a derivative of BSD which is from Berkely 4.3, says the -r (recursive) You can use this option when the destination is a directory. If any of the files in the source-file-list is a directory, the -r option will cause cp to copy the contents of that directory and any of its subdirctories into the destination-directory. The subdirectories themselves are copied as well as the files they contain.


Format: cp [options] source-file-list destination-directory


Hope this helps.

Nov 1, 2011 7:18 AM in response to evets90

The safest way to enter the copy command with the correct argument would be the following:

(This will automatically generate all necessary escape characters in the pathnames)


when in Terminal type (as suggested by Ralph Landry):


sudo cp -R (followed by a "space char", but no "enter" or "return")


  • Now drag the application you want to copy right into the Terminal Window, this should generate the correct pathname to the Application,
  • again enter a "space"
  • Now drag the Applications Folder right into the Terminal Window, to generate the pathname,
  • read the expanded command carefully, if the filenames appear to be correct
  • hit the return key.


This will recursively copy your app to the Applications folder. The prefix "sudo" will allow you to do this in Administrator mode, since the Application Folder is protected. You will be asked for your Administrator password.

Nov 1, 2011 12:57 PM in response to léonie

leonieDF wrote:


The safest way to enter the copy command with the correct argument would be the following:

(This will automatically generate all necessary escape characters in the pathnames)


when in Terminal type (as suggested by Ralph Landry):


sudo cp -R (followed by a "space char", but no "enter" or "return")


  • Now drag the application you want to copy right into the Terminal Window, this should generate the correct pathname to the Application,
  • again enter a "space"
  • Now drag the Applications Folder right into the Terminal Window, to generate the pathname,
  • read the expanded command carefully, if the filenames appear to be correct
  • hit the return key.


This will recursively copy your app to the Applications folder. The prefix "sudo" will allow you to do this in Administrator mode, since the Application Folder is protected. You will be asked for your Administrator password.


I just tried this with a test app and it didn't seem to copy the entire application (I used the Caffeine App as a guinea pig), it only seemed to copy the "Contents" folder. I tried a lower case and upper case -R switch as well as an -ri switch with the same results. Any way to make it a full self contained app?

Copy/replace an Application via Terminal

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.