view raw
Edccccch Edccccch - 9 months ago 45
Linux Question

how to use array in sed shell command?

I am trying to do a list of name:

list = a, b, c, d, e
sed "/$list/d" output_file.txt

so that lines containing those variables a,b,c,d,e would be excluded from the output_file

Anyone please help


With GNU grep:

list=(a b c d e)
(IFS="|"; grep -vE "(${list[*]})" output_file)