linux : Search in files script

A super linux ability : find files containing certain words.
but typing the command (even remembering it! ) is anoying.
Lets create a quick script to ease the use !

sudo nano /usr/bin/myfind

if [ $# -eq 0 ]
    echo "No arguments supplied"
grep -rnw -A1 -B1 './' -e "$1"

Type : myfind aword
to list every file containing « aword » in the current directory and his subfolders (recursive !)

Laisser un commentaire