Searching Through Files in Linux

I do more & more Linux work from the shell, and it’s starting to grow on me. πŸ˜‰

I used to search through files using this command

find . | xargs grep -s 'keyword'

but now & again get errors like xargs: unmatched single quote; by default quotes are special to xargs unless you use the -0 option

So I found this command works instead

find . -printf '"%p"n' | xargs grep -s 'keyword'

or you can make a handy shell script (e.g. search.sh) like this

#!/bin/bash

find . -printf '"%p"n' | xargs grep -s "$1"

and then search files like

search.sh 'keyword'
0