49.3k views
3 votes
Garrett wants to search through a csv file to find all rows that have either the name John or Bob in them and display them out to the terminal. Which of the following commands could Garrett use to perform this search?

a. grep -E "(John|Bob)" salesemployees.csv
b grep -E (John|Bob) salesemployees.csv
c. egrep (John|Bob) salesemployees.csv
d. grep (John|Bob) salesemployees.csv

1 Answer

2 votes

Answer:

A. grep -E "(John|Bob)" salesemployees.csv

Step-by-step explanation:

The grep command is used to search text. It searches the given file for lines containing a match to the given strings or words.

How to use Grep Command:

grep 'letter' filename – Search any line that contains word 'letter' in filename on Linux

grep -i 'Alphabet' file1 – A case-insensitive search for the word ‘Alphabet’ in Linux and Unix

grep -R 'root' . – Search all files in the current directory and in all of its subdirectories in Linux for the word ‘root’

User Chris Koenig
by
3.6k points