cheat sheets.

$ cheat grep
--- grep version 5	Mon Sep 01 16:59:38 +0000 2008
+++ grep version 6	Thu Sep 04 20:19:37 +0000 2008
@@ -1,58 +1,76 @@
 Overview
 ========
 grep searches for lines matching a pattern.
 
 $ grep [OPTION]... PATTERN [FILE] ...
 
 PATTERN can be a normal string or a regular expression. For more on regular
 expressions see:
 $ cheat regexp
 
 Get full help:
 $ grep --help
 
 Basic Usage
 ===========
 $ grep index *.rb
 admin_controller.rb:  def index
 store_controller.rb:  def index
 store_controller.rb:    redirect_to_index 'Invalid product'
 store_controller.rb:      redirect_to_index "Your cart is currently empty."
 
 
 Useful Options
 ==============
 -h:   suppress file names in output
 -w:   restrict search to whole words only
 -c:   displays count of matching lines in each file, not the lines themselves
       (note this is not the same as $ grep index *.rb | wc -l)
 -i:   ignore case
 -l:   list only file names containing matching lines
 -n:   precede each line with the line number where it was found
 -v:   display all lines NOT matching pattern
 -C:   Display NUM lines of context either side of matches
 -e pattern: 
       Search for a pattern. Can use multiple times on a line
 -r:   Search recursively from the current or specificed directory
   --include=pattern:
       Only search in file names matching pattern
   --exclude=pattern:
       Do not search in file names matching pattern
 
 Examples
 ========
 
 Recursive search, multiple patterns:
 
 $ grep -r --include=*.rb -e "TagsHelper" -e "tags_helper" .
 ./app/models/foo.rb:  include TagsHelper
 ./app/models/bar.rb:  include TagsHelper
 ./vendor/plugins/acts_as_taggable_on_steroids/lib/tags_helper.rb:module
 TagsHelper
 ./vendor/plugins/acts_as_taggable_on_steroids/test/abstract_unit.rb:require_depen
 ency File.dirname(__FILE__) + '/../lib/tags_helper'
 ./vendor/plugins/acts_as_taggable_on_steroids/test/tags_helper_test.rb:class
 TagsHelperTest < Test::Unit::TestCase
 ./vendor/plugins/acts_as_taggable_on_steroids/test/tags_helper_test.rb:  include
 TagsHelper
+
+# Count the number of functions in all JS files
+grep -c function *.js
+
+# Print lines that DO NOT have &quot;function&quot;
+grep -v function *.js
+
+# List processes that match &quot;pidgin&quot; (non-Windows)
+ps -ef | grep pidgin
+
+# Print a list of: function &lt;function-name&gt; and sort it
+grep -Eho &quot;^\s*function \w+&quot; *.js | sort
+
+# Print filenames, line #s, and lines that start with &quot;(white space)function&quot;
+grep -EHn &quot;^\s*(function \w+|\w+ \= function)&quot; *.js
+
+# Print only duplicate function names
+grep -hEo &quot;^\s*function \w+&quot; *.js | sort | uniq -d
( add new | see all )