http://www.mitchchn.me/2014/and-eight-hundred-more/
On Wednesday night I went to bed pretty pleased with myself. My article abut the OS X command line had captured the attention of a few hundred visitors that evening. I’d even received a bit of feedback. Not bad for a week-old personal blog, eh?
I was in for one hell of a surprise. When I woke up on Thursday morning—my 25th birthday—the number of pageviews had reached 30,000. By Friday evening, just over 100,000 people had seen my article. And it feels like a good tenth of them have responded in some way: comments, compliments, and criticism. Gratitude. Typo corrections. Sage advice. Birthday wishes.
To someone entirely unused to online notoriety, it feels as though a very geeky flash mob materialized in my apartment one evening, stayed for dinner, then went home and reviewed my cooking on Yelp. I am a little dazed.
With any luck, at least a few of those visitors will invite themselves back. The Terminal post was meant for a more technical audience than my main series, Coding for Journalists. But it won’t be the last of its kind. And one of my goals for this place is to explore some of the more basic topics in hackerdom in a way that’s compelling for people of different backgrounds and skill levels. I hope I’m succeeding.
Of course, there are far more than just eight utilities every Terminal user should know.
In the past couple days, dozens of people have shared with me their own favourite Terminal one-liners and scripts. I’ve learned new tricks about the tools I covered in my article, and discovered others I’d rarely or never touched. In fact, the best thing about the reaction to my article wasn’t the feedback directed at the post, my blog, or myself; it was the discussion that spawned all around the Mac-o-sphere about the command line and how to make the most of it.
I’m going to highlight a few of the more interesting utilities I missed in this post. It’s also worth taking a look at the comment section on Hacker News. There are troves of good information out there from people much more knowledgeable than I will ever be.
And now, in no particular order, the shortlist:
I covered open previously, but it deserves an encore for a feature several people brought to my attention. Typing open -a Safari will launch Safari—no matter where Safari is located on the system. The same shortcut works for any Mac application. There’s no need to have the full path.
This black magic is made possible thanks to Launch Services, the same system that associates filetypes with their applications in Finder. Thank you to all the users on reddit and Twitter who introduced me to this trick.
textutil uses Cocoa’s text engine to manipulate documents and convert them between various formats, including .doc, .txt, .html and .rtf. For example, here’s how to make an HTML file out of a simple Word document:
$ textutil -convert html article.doc
Another interesting feature of textutil is its ability to concatenate (join together) multiple files into one long document. This command will join three Word documents together into one .rtf:
$ textutil -cat rtf article1.doc article2.doc article3.doc
Thanks to cstross from Hacker News for teaching me about textutil.