Reputation: 829
I have an array which contains list of strings.
Example: array = ("Sample","Test","Check").
I need to pass this to grep command to exclude these string while getting results. So, In the output I should not have ("Sample","Test","Check") terms. Please help me.
Upvotes: 1
Views: 4189
Reputation: 2654
It can be done the following way:
grep -v -e string_to_exclude_1 -e string_to_exclude_2 file_name
For example, the following command excludes check.xml and test.xml from a file named sample.txt
grep -v -e check -e test sample.txt
sample.txt contains the following:
one.xml
two.xml
three.xml
test.xml
check.xml
Upvotes: 1