Mac-terminal.com

Mac-Terminal.com

An introduction of the Terminal for Mac OS X

ditto

Syntax: ditto [-Options] <source> <target>
ditto [-Options] <source directory> <target directory>
ditto [-Options] <compressed archive (.zip)> <target directory>
ditto [-Options] <file(s)/folder(s)> <compressed archive (.zip)>

Usage/Result: Copy one or several file(s)/folder(s) to another location.
Copy one directory to another.
Extract the content of a compressed archive.
Add file(s)/folder(s) to a new compressed archive (.zip).

Options:

-cCopies the chosen files/folders to a compressed archive (target location must end with .zip, .cpio eller .cpgz (Compressed CPIO-archives).
-VOutput the path to the files/folders as they are being copied.
-xExtract files from a compressed archive (.zip). (source file must be a valid compressed archive like a .zip).

Exempel

ditto myfile.txt DocumentsCopies the file myfile.txt to Documents.
ditto Documents "Documents Backup"Creates a copy of the directory Documents called Documents backup (Whenever you're using spaces in a path you must surround it with quotes).
ditto archive.zip DocumentsExtract the content of archive.zip to the Documents directory.
ditto Documents archive.zipCreates a new compressed archive containing the Documents directory.

Quick tip: Sometimes you might not be able to perform a certain command or task from the Terminal. This might be because you don't have the right permission to do so. When that happens you can try to add the word "sudo" in the beginning of the line.
Sudo is an abbreviation of superuser do and means that you want to execute the following command as a user with extended permissions, most often as an Administrator. When using "sudo" you sometimes need to enter the password of the root account.
Learn more about sudo.