I've got some work to do in bash. It goes like this:
As first argument you type words to find it in the files in the order that it is written, in the second argument you type the directory. It has to search recursively and return the file name where it appears.
For example: bash mybash "alice cat" .
it should return files that contains for example: "alice has a cat", "alice cat", but not "cat has alice"
I did smething like this
#!/bin/bash
pattern=".*"
for arg in $1; do
pattern+="${arg}.*"
done
grep -r ${pattern} $2
but it searches only line by line and doesn't find files with:
"alice something else"
"new line has a cat"
but it should return it.
Some help would be appreciated.
Greets.