The Mac Observer

BBEdit’s Command Line Functions

November 5th, 2009 at 3:04 PM - How-To by John Martellaro

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.

  • Related Entries
  • Email This
  • Tweet This
  • John Martellaro on Twitter

1 Observer Comment

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

Page 1 of 1 pages
Login. Need an account? Register here.



Auto-login on future visits

Show my name in the online users list

Forgot your password?


Post A Comment

Name:

Email: (will not be displayed)

Location:

URL:

  Your Comments

Remember my personal information

Notify me of follow-up comments?

Submit the word you see below:


 

Recent Headlines - Updated November 20th

Fri, 7:07 PM
Games - Soccer Sim Championship Manager 2010 Released for Mac
6:47 PM
Games - EA Publishes Original Monopoly for iPhone
6:15 PM
News - Original Apple I on Ebay for $50K, w/Letter from Steve Jobs
6:11 PM
Games - New iPhone Games: Secret of the Lost Cavern Ep 1, New DJ Nights, More
5:47 PM
Games - Star Trek D-A-C Game Headed to the Mac Next Month
4:57 PM
Product News - TidBITS Releases “Take Control of Syncing Data in Snow Leopard”
4:26 PM
John Martellaro's Blog - Particle Debris (week ending 11/20) Stationery Pads Go Poof
2:59 PM
Free on iTunes - Musée du Louvre, Art Lite, SketchBook Mobile X and More.
1:50 PM
Deal Brothers - Acer P215H bmid 21.5” Widescreen LCD Monitor:  $139.99
11:24 AM
TMO Appearances - Jeff Gamet Shares More Holiday Gift Ideas on MacJury
10:43 AM
Product News - Cocktail 4.5 for Leopard Adds QuickLook Cache Clearing
10:06 AM
News - Hack Enables Mac OS X 10.6.2 on Netbooks
 

The Mac Observer Reader Specials

  • TypeStyler For Mac OS X is Now Shipping! Download The Free Fully Functional 60 Day Tryout at www.typestyler.com
  • RamJet Memory: Mac Pro 8-core 8GB Kit $249.99, 4GB Kits $149.99! Sale on MacBook and MacBook Pro 8GB kits $497.99! New MacBook DDR3 4GB for $109.99. iMac and Mac mini 4GB Kits for $109.99! 1TB SATA Hard Drives for $109.99! Click here
  • OWC: Get the Right Memory for Your Mac Top Quality, Competitive Price, Lifetime Backed Free Expert Support + Installation Videos too! MacBook & mini 8GB, iMac 16GB, Mac Pro up to 32GB. Click here
  • Poker Mac If you're using a Mac, then you've gotta check out Full Tilt Poker for Mac. This Full Tilt Poker bonus code does the unthinkable, it actually rewards!
  • For the latest Apple products use Ciao, a price comparison website, to find laptops like MacBook Air. Then find the best prices on MP3 players and use our comparison tool to evaluate mobile phones like the Apple iPhone.

  • Laptop Hardware Provided by TechRestore - Overnight Mac & iPod Repairs.
  • Buy Stuff, Support TMO!
  • __________
  • Macworld Expo 2010 Hotel Deal
  • TMO on Twitter!

Apple Stock Quote

  • AAPL: $199.92. Change: -0.59.
  • (Prices delayed up to 20 minutes.)
  • Discuss in our Apple Finance Board

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