I have 2 bash functions catall and grepall
catall
works fine, catting every file it finds with the file name printed first, then the content and a new line
catall ()
{
find . -name $1 | xargs -I % sh -c 'echo %; cat %; echo"" '
}
grepall ()
{
find . -name $1 | xargs -I % sh -c 'echo %; cat % | grep $2; echo"" '
}
But grepall
doesn't work, is should do the same as catall
but with a grep stage on the content of the file
Why is $2
not sub'ed
Can you make this grepall work ?