linux - Filter lines with the other set of lines in Bash -


i have lines on standard input

$printf "c\nb\na\n" c b 

and want filter out lines (or substrings or regexps - whatever easier) appear on other standard input:

$printf "b\na\n" b 

i expect c when entries filtered.

i've tried

$printf "c\nb\na\n" | grep -v `printf "b\na\n"` 

but i'm getting

grep: a: no such file or directory 

how can perform filtering of standard input lines returned other command?

you can use grep's -f option:

matching control     -f file, --file=file           obtain patterns file, 1 per line.           [...] 

and use <(command) syntax using command's output content used:

$ printf "c\nb\na\na\nc\nb" | grep -vf <(printf "a\nb\n") c c 

Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -