RSSCategory: Terminal

mkdir

Well this is just a qick post as I’m sure everyone is aware of this trick. Well not everyone as I recently had aconversation with a colleauge over the quickest way to create nestled folders. My answer was open terminal and type your folder structure such as…

mkdir -p ~/folder/folder1/folder2/folder3

Just about as fast as it gets….

September 22, 2014 | By | Reply More

ditto

Another commandline gem is ditto (man ditto).

This command, called “ditto,” not only copies the files from the source directory to the destination directory, but creating the destination directory if it doesn’t already exist. It will also merge the contents of the source directory with the destination directory if it exists.

It will follow symbolic links and hard links when copying files and will also preserver permisions and metadata. Which comes in really handy if you are working on say the ‘User Template’ folder for example.

Runing ditto is a snap…

ditto ~/Documents/MyFolder ~/Desktop/MyNewFolder

That would copy MyFolder to the Desktop creating the MyNewFolder if it didn’t already exist.

If you would like to see the verbose output the simply add ‘-V’ before the source folder.

ditto -V ~/Documents/MyFolder ~/Desktop/MyNewFolder

If you need more info on other options again type man ditto.

September 22, 2014 | By | Reply More

Open

Open
Command Line Tools

If you are like me and you spend some time in terminal then this awesome command line tool can if use correctly save you a chunk of time.

Usage: open [-e] [-t] [-f] [-b ] [-a ] [filenames]
Help: Open opens files from a shell.
Help: Open opens files from a shell.
By default, opens each file using the default application for that file.
If the file is in the form of a URL, the file will be opened as a URL.
Options:
-a Opens with the specified application.
-b Opens with the specified application bundle identifier.
-e Opens with TextEdit.
-t Opens with default text editor.
-f Reads input from standard input and opens with TextEdit.
-g Does not bring the application to the foreground.
-R Selects in the Finder instead of opening.

To open a file simply type open -a textedit.app ~/Desktop/text.txt. If you want to open this file in the background the simply type open -g textedit.app ~/Desktop/text.txt. If textedit is your default editor then save yourself a little more time by using open -e ~/Desktop/text.txt again add the -g flag to open in the background. Now to open the file in your default editor as determind by LaunchServices use open -t ~/Desktop/text.txt.

To reveal the location of the file insted use the -R flag as in open -R ~/Desktop/text.txt This I find extremely helpful editing a file that has a long path. Of course you can edit files in VIM but thats for another day.

For more info type man open.

August 31, 2014 | By | Reply More