How can I turn the following command into a bash alias?
find . -name '*.php' | xargs grep --color -n 'search term'
Where I can specify the file extension and 'search term' is obviously the search term :)
So what I want to do is:
searchFiles 'php' 'search term'
How do I pass the input into the alias? Should I just create a bash script and have the alias point to the script?
How about using a function? Add this to your .bashrc:
function searchFiles() {
find . -name \*."$1" -print0 | xargs -0 grep --color -n "$2"
}
and then use it like:
$ searchFiles c include
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With