Grep multiple strings from a file

broken image

When you run this command, you'll get back a list of every line in the document containing the word bee or the word Vanessa. The syntax looks like this: grep -E 'bee|Vanessa' ~ /work/beescript.txt Let's say, for example, you wanted to find every occurrence of the words bee and Vanessa in a text document containing the script from the 2007 Bee movie.

broken image

This syntax, using the ~ and /, followed by the location of the file in the home folder, is what you'll use to show the grep command which files to search.

broken image

For example, if you wanted to enter the path for a text document located in a folder called work inside the home folder, you'd reference it using this format: ~ /work/textdocument.txt You'll also need to be familiar with how to reference files by path using the terminal. Looking for Something How to grep Multiple Strings in Linux. First, you'll need to be able to bring up a terminal-on most systems, you do this with the key combination Ctrl + Alt + T, or via the applications menu. Example 2: Grep for multiple strings in single file.

broken image

Searching Multiple Strings in grepīefore getting started, you'll need to make sure you are familiar with a few Linux basics. This article focuses on how to search multiple strings using grep and will show you a few similar tips and tricks for using grep in general.

broken image