I got a file on desktop, file name is ded.html. To copy the file, I click the file and press cmd+c.
Now how would I do the same thing using terminal ?
|
|
If I'm understanding the question right, what you're after is Open a terminal and do:
Now that file is in the clipboard. To put it somewhere else, that is, to paste it, do:
Now you should have a copy of ded.html sitting in ~/Documents. |
|||||||
|
|
Lri’s answer is headed in the right direction, but it has a couple of flaws: there is no need to use Finder ( Here is my version (wrapped in a shell function—you could put this in (e.g.) your
A file that has been put on the clipboard with this script can then be pasted in Finder to copy the file to another folder. osascript can also be used as a hash-bang interpreter (since 10.5). Put this in a file (e.g.
Make the file executable (
If it is stored in a directory in the PATH, then you can omit the path to the “script” file. |
|||
|
|
There is no way to achieve what you are trying to do using the command line. While Apple offers the Without going in to too much technical detail, when you 'copy' a file in the Finder using ⌘C, you're not actually copying the file itself, just making a reference to the file on the clipboard and marking it as a file reference. When an application receives this reference when you paste, it has the responsibility of sorting things out, figuring out what you pasted, and ultimately, working with the file as it sees fit. In essence, when you copy a file in the Finder, it saves the path to the file in a certain way to a certain clipboard, and when you paste, it receives that file path and knows to create a new file using the contents of the old one (copy a file to the clipboard, delete it, try to paste it somewhere else, and see what happens, for instance). In this sense of copying and pasting, the tools available at hand are not enough to do what you need. As boehj suggested, you can try to copy the contents of the old file into a new one, but this will only work well for text files. Any binary files you get will be corrupted (try doing this with an image – it becomes corrupted). The traditional command line will fail you in this way, but you can take a look if you'd like into doing this in AppleScript, then invoking that through the command line with |
|||||||||||||||||
|
|
To copy a file to a destination, use the
See |
|||
|
|
I don't know any way to copy multiple files though. |
||||
|
|