Skip to content

Instantly share code, notes, and snippets.

@figital
Created February 9, 2011 21:12
Show Gist options
  • Save figital/819293 to your computer and use it in GitHub Desktop.
Save figital/819293 to your computer and use it in GitHub Desktop.
fstring
#! /bin/bash
# description: search a directory for a string, output filenames and context
# usage: fstring /tmp/whatever mysearch
# example: fstring ./ hello (search current directory for string "hello"
# better example:
# sfitchet@crunchbang:/tmp/myapp$ fstring ./ array_slice
# ./docs/code-reviews/rick.txt:5. /public_html/widgets/twitter/index.php //
# line 16, for perf, cache array_slice($tweets, 0, 5) in a var, PHP is //
# dumb and will actually run # that code EVERY time the loop runs
# ./public_html/widgets/twitter/cache.php: $tweets = array_slice($tweets, 0, 5);
# installation: sudo cp fstring /usr/local/bin
find $1 -type f -exec grep $2 \{\} /dev/null \;
@figital
Copy link
Author

figital commented Feb 9, 2011

I think I should make the directory parameter optional ... since you'd normally already be in the location you're about to search, right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment