The code below works, it's a part of a bash shell script that serve to search a pattern $pattern_da_cercare in the files contained in a directory $directory_iniziale.
Now the proble is:
How can I redirect stderr to a file?
PS: so I want to redirect ALL the errors to a file.
I tryed to learn how to do it, but I haven't understood
find $directory_iniziale -type f | while read file
do
awk -v min=$MIN -v max=$MAX -v patt=$pattern_da_cercare '
BEGIN{RS=" |\n"; patt = "(^|[^A-Za-z0-9])" patt "([^A-Za-z0-9]|$)" }
$0 ~ patt {n++}
END {
if(n >= min && n <= max && n != 0) {print FILENAME " : " n}
}
' "$file"
done
quine has told you how to do that with command line, then when you posted it didn't work when you placed it in the script, I posted "not in the script but on the command line".
The only other alternative, is the 2nd option, "within the script", and yes, you'd then need to put on every line there is output..... so why not put it on the command line?? it sounds like want you're wanting to do.
Suggestion: try it! if it doesn't work, post exactly what you typed, and the resulting output.