Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

would like to write a bash program which if I type in the following:

-bash-4.1$ ./sample.sh path regex keyword

that will result something like that:





I have absolutely no idea how can I achieve this without using find or grep -r (but I can use grep/ sed/ awk) in bash... Please help...

Thank you very much!!

share|improve this question

closed as too localized by Gilles, Michael Mrozek Jan 9 '13 at 3:30

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

shopt -s globstar
awk '/search-string/ { print FILENAME ":" NR }' **/*

globstar enables recursive globbing. NR holds the current line number.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.