Grep multiple strings from text file

前端 未结 3 525
没有蜡笔的小新
没有蜡笔的小新 2021-01-19 00:39

Okay so I have a textfile containing multiple strings, example of this -

Hello123
Halo123
Gracias
Thank you
...

I want grep to use these st

3条回答
  •  青春惊慌失措
    2021-01-19 01:24

    You should probably look at the manpage for grep to get a better understanding of what options are supported by the grep utility. However, there a number of ways to achieve what you're trying to accomplish. Here's one approach:

    grep -e "Hello123" -e "Halo123" -e "Gracias" -e "Thank you" list_of_files_to_search
    

    However, since your search strings are already in a separate file, you would probably want to use this approach:

    grep -f patternFile list_of_files_to_search
    

提交回复
热议问题