2

On zsh shell, I put into my ~/.zshrc the following function :

ff () {
    parallel -j8 find {} -type f ::: $1/* | grep -i $2
}

The goal is to do a "parallel" version of classical find function.

But unfortunately, it doesn't seem to work : for example, in a directory containing R scripts, I am doing :

ff . '*.R'

But this command doesn't return anything. What is wrong with my function ff?

halfer
  • 19,824
  • 17
  • 99
  • 186

2 Answers2

2

(Posted the solution on behalf of the question author to move it to the answer space):

Thanks to answer, the following works fine:

ff () { parallel -j8 "find {} -type f -name '$2'" ::: $1/*;}
halfer
  • 19,824
  • 17
  • 99
  • 186
1

By default grep uses basic regular expressions, so calling the function with another asterisk should work

ff . '**.R'

to ignore files like foo.r.bar

ff . '**.R$'
SirNoob
  • 51
  • 9
  • thanks a lot. Which are the modifications to do on my function `ff` to have the same syntax as classical `find` function, tha is to say : find . -type f -name '*.R' ? Regards –  Sep 26 '21 at 15:03
  • notice the double quotes without them find does not recognize the regex `parallel -j8 "find {} -type f -name '*.[R|r]'" ::: ./*` – SirNoob Sep 26 '21 at 15:13
  • with the -iname flag the match is case insensitive – SirNoob Sep 26 '21 at 15:22