I'm performing a nested grep like this:grep -ir Some string . |grep Another string I want to find in the other grep's resultsThis works perfectly as intended (I get the results from the first grep filtered by the second grep as well), but as soon as I add an -l option so I only get the list of files from the second grep, I don't get anything.grep -ir Some string . |grep -l Another string I want to find in the other grep's resultsThis results in the following output:(standard output)I guess piping doesn't work when I just want the list of files. Any alternatives?
Nested piped grep results in a string saying (standard input)
grep;pipe
use cut to remove strings after : then you get file parts (assuming file paths don't contain colon or newline characters and don't match the second pattern themselves).grep -ir Some string . |grep Another string I want to find in the other grep's results | cut -d : -f 1in case of duplications use uniqgrep -ir string1 . | grep string2 | cut -d: -f1 | uniq