bash

Posted by Jeet Sukumaran

Introduction

Here is a way to create a secondary shell history log (i.e., one that supplements the primary "~/.bash_history") that tracks a range of other information, such as the working directory, hostname, time and date etc. Using the "HISTTIMEFORMAT" variable, it is in fact possible to store the time and date with the primary history, but the storing of the other information is not as readibly do-able.

Posted by Jeet Sukumaran

This is pretty slick: enter "fc" in the shell and your last command opens up for editing in your default editor (as given by "$EDITOR"). Works perfectly with vi. The"$EDITOR" variable approach does not seem to work with BBEdit though, and you have to:

$ fc -e '/usr/bin/bbedit --wait'

With vi, ":cq" aborts execution of the command. Not sure how to do the same thing with BBEdit.

Posted by Jeet Sukumaran

Here are three confessions:

Grep a Glob

04 Oct 2008
Posted by Jeet Sukumaran

Ever wanted to search a group of files, as specified by a glob pattern, for some content, as specified by a grep pattern?

find -path '' -exec grep -iHn {} \;

Note that the GLOB-PATTERN should be quoted to prevent the shell from auto-expanding wildcards before passing them to find.

Examples:

find /Applications -path "*.app/Contents/Info.plist" -exec grep -iH python {} \;