Skip to content

Instantly share code, notes, and snippets.

@alexliang1975
Created September 3, 2012 17:54
Show Gist options
  • Save alexliang1975/3611362 to your computer and use it in GitHub Desktop.
Save alexliang1975/3611362 to your computer and use it in GitHub Desktop.
Find file which include string without grep
find . -type f -exec awk 'BEGIN{n=0} {if($0~/'"$1"'/){a[n++]=FNR" "$0}}END{if(n>0){print(FILENAME); for(i=0;i<n;++i) print a[i] }}' {} \;
@alexliang1975
Copy link
Author

This is a awk shell to find files which includes the string without grep command.
For example:
$findWithoutGrep.sh london

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