The Mac Observer

BBEdit’s Command Line Functions

TMO Talk (1)

With BBEdit 9.3, a new terminal command has been added: bbfind. That's in addition to the previously available commands: bbedit and bbdiff. Here's a brief introduction on how to use these commands.

Programmers and sysadmins often use BBEdit to write code or scripts. As a result, it's often handy to have a helpful integration between a GUI text editor and the UNIX shell. That kind of elegant pairing is what makes working with the Mac so much fun.

Here are the the three commands that BBEdit can install into the underlying UNIX system, if requested:

  1. bbfind - a multi file search function that displays the files and their paths a search terms appear in.
  2. bbedit - launch the BBEdit editor from the command line and edit files.
  3. bbdiff - find the differences between two similar files.

You install these commands by using the menu item "Install Command Line Tools..." under the main BBEdit menu. An admin password is required, so you'll need to be an administrator of the Mac to install them.

The installation of the commands also results in entries inserted into the UNIX man pages. I find the use of 'man' on the command line cumbersome, so I use the Mac OS X Universal app called "Man Viewer.app" by Peter Kendall. It has a nice filter function that allows you to home in on just what you need.

Man Viewer

Man Viewer

1. bbedit: This one is as simple as typing: "bbedit filename". Here's an example of editing the plist file that determines whether Snow Leopard will boot into a 64-bit kernel. (I've rearranged the windows a bit for clarity and space.)

bbedit filename 2

$ bbedit com.apple.Boot.plist

You can edit system files this way, so long as you are an administrator because BBEdit will ask for your admin password to edit files owned by root. (Note, this  command is more just another way to use the Darwin "open" command, as in, $ open -a /path/to/app/appname.app). For example, for example, you can make it the target of a pipe:

$ find /var/log -name "*.log" -print | bbedit

2. bbdiff: This one can be as simple as typing: "bbdiff filename1 filename2". The command will open three BBEdit windows, one showing each file and a third that lists all those lines on which a difference was found.

bbdiff 2

$ bbdiff com.apple.Boot.plist com.apple.Boot-copy.plist

bbdiff result 2

Result in red - in bottom window - lists differences

3. bbfind: This is new in BBEdit 9.3. It can be duplicated, more or less, mostly less, with the Finder's CMD+F find function, but not as elegantly, and not as fine tuned with specialized arguments.

For example, you can do finds of strings that only occur on word boundaries, search as case-sensitive, search invisible folders. There's a whole slew of other commands the can help winnow the search. An abbreviated list of the command line arguments is in the link to the release notes above. The man page has even more detail. Here's an example of a find I did on the term "rosetta" in Users/john.

bbfind result

$ bbfind --gui rosetta /Users/john

BBEdit is a terrific text editor that just keeps getting better and better. For example, BBEdit 8.6 introduced the ability to edit property lists that have been saved as binary files. For those programmers and sysadmins who work on the command line, these supplemental command line functions provide them even more power when it comes to building scripts and managing a Mac OS X system.

Post A Comment or Log-in. Need an account? Register here.

1 Observer Comment

   Actions John Martellaro said on November 5th, 2009 at 3:38 PM (Edited: 07/29/2011 1:39 PM):

I’m exploring ways to make these graphics bigger and clearer. Stand by for a bit.

 

Recent Headlines - Updated February 11th

Fri, 8:10 PM
News - Apple Sues Motorola Mobility in California Over German Case
7:54 PM
Free on iTunes - OnLive Desktop: Windows & Office on Your iPad
7:43 PM
Product News - Apple Rolls Out MacBook Air Configurations for Education
6:35 PM
Just a Peek - Battle Pocket Bulge With The Hint for iPhone
6:01 PM
Rumor - Apple Reportedly Bringing MacBook Air Styling to Pro Line
4:50 PM
Particle Debris - The Hidden Gotchas of Browser Security
3:56 PM
Apple Stock Watch - Analyst: Paying a Dividend Makes Sense for Apple
2:58 PM
Deal Brothers - iMac 27-inch 2.93GHz Intel Quad-Core i7 processor:  $1,999
2:45 PM
In-Depth Review - Theodolite App for iOS is Breathtaking
12:52 PM
Apple Stock Watch - Mizuho Securities Starts Apple Coverage with $635 Target
11:35 AM
Hot Forum Topic - Forum Poll: Are You Planning on Buying a New iPad?
11:00 AM
Analysis - Competitors Size up Apple’s iBooks Author
 

The Mac Observer Reader Specials

  • TypeStyler 11 is now in the Mac App Store!! -- Special Introductory Price of $59.95!! -- To Buy From The Mac App Store Click Here Now!! Or buy direct from Strider Software.
  • Mac RAM Upgrades: MacBook Pro 16GB kits $475, 8GB Kits for $119.99! iMac 16GB RAM Kits (4x 4GB) for $229.99! Mac Pro Memory 32GB Kit for $399.99, 64GB Kit for $889.99! Mac Hard Drives 2TB Seagate SATA II for $249.99! Click Here!
  • Poker Mac If you're using a Mac, then you've gotta check out Online Poker Mac. This mac poker and online casino mac site actually does the unthinkable, it actually rewards!

Apple Stock Quote (AAPL)

Loading...

Hot Topics

TMO Express

Join the TMO Express Daily Newsletter to get the latest Mac headlines in your e-mail every weekday. Find out more!

Top Deals From DealBrothers.com

Recent Features

Support The Mac Observer

We noticed you may be running AdBlock on your computer. It takes real money to run this site and to deliver the news, tips, and opinions you love to read.

If you wish to block the ads that pay for the creation of our content, we ask that you instead support TMO Directly, either with a $5 monthly recurring contribution, or a one-time donation of any amount of your choice. Thanks!

Subscribe with Paypal Donate with Paypal