Filed under: UNIX / BSD, TUAW Tips
Monday man page: open
Just a quick hint for today's man page: the open command does just what you might think. It opens files, directories, applications or URLs; no muss, no fuss. For files, you can specify an application to open them with the -a flag (or just trust LaunchServices to pick the right app). If you want to, the -e flag will force them to open in TextEdit.
open ~/Desktop/MyWordDoc.doc [will open in MS Word]
open -e ~/Desktop/MyWordDoc.doc [will open in TextEdit]
open ~/Desktop/*.doc [opens every Word document on the desktop, in Word]
open http://tuaw.com [well, give it a go!]
I use open in installation scripts or other situations where I want a GUI application to come up at the end of a process. For example,
open /System/Library/CoreServices/Software\ Update.app/
launches Software Update and begins checking for available patches. Sure, you can force an update with 'softwareupdate -i -a' anytime, but maybe I want to give the person sitting at the console an opportunity to select the updates needed, or cancel out of the possibly-lengthy update cycle until it's more convenient. You could also use the URL functionality to take people to a 'readme' website... the possibilities are manifold.

![TUAW [Cafepress]](http://www.blogsmithmedia.com/www.tuaw.com/media/tuaw-cafepress-promo.png)


Reader Comments (Page 1 of 1)
tim said 2:22PM on 2-12-2007
these are great posts, mike! im glad you are here!
after mac addict turned to mac|life, i lost most of my every day mac stuff that has at least some 'power user' tips. nice to see you are keeping it alive.
Reply
Tom said 3:32PM on 2-12-2007
"open" is one of the commands I miss most when I'm using an OS other than Mac OS X, although there's probably something similar.
Anyway, other good uses:
open -a SubEthaEdit mytextfile.txt
(opens mytextfile.txt in SubEthaEdit, replace SubEthaEdit with application of choice)
open .
(yes that's a period, opens a new Finder window with your current directory...basically the opposite of dragging a file or folder to the Terminal to get the path)
open -a TextMate .
(we can combine the previous two examples: if your app, TextMate in this case, can open a folder for browsing this will open the current directory in that app)
Reply
Michael Rose said 5:07PM on 2-12-2007
Thanks Tom & Tim -- much appreciated.
Reply
starwxrwx said 7:34PM on 2-12-2007
I'm looking for a way to open iTunes remotely - ie, I log into my machine via ssh and want to start iTunes. But if I try to use open obviously it can't access the display where I am and refuses to open - but I want it to open on the local machine so I can get to my Tunes via Sharing - any ideas??
Reply
claytron said 9:44PM on 2-12-2007
@2
instead of doing
open -a SubEthaEdit mytextfile.txt
you can use the 'see' command from SubEthaEdit (Installable via prefs -> advanced in SubEthaEdit)
see mytextfile.txt
I know this is about using open but see is nice too! Similar command line tool for TextMate too, 'mate'.
Reply