MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

UNIX

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
Which command searches a file or files for lines that have a certain pattern?
A
erep
B
pgrp
C
grep
D
drep
Explanation: 

Detailed explanation-1: -Use the grep command to search the specified file for the pattern specified by the Pattern parameter and writes each matching line to standard output . This displays all lines in the pgm. s file that begin with a letter.

Detailed explanation-2: -The grep command searches through the file, looking for matches to the pattern specified. To use it type grep, then the pattern we’re searching for and finally the name of the file (or files) we’re searching in.

Detailed explanation-3: -To find a pattern that is more than one word long, enclose the string with single or double quotation marks. The grep command can search for a string in groups of files. When it finds a pattern that matches in more than one file, it prints the name of the file, followed by a colon, then the line matching the pattern.

Detailed explanation-4: -Expert-Verified Answer. (a) GREP command is used for searching a pattern in a file. The most useful and versatile commands in a Linux terminal environment is the “grep” command as well as the name “grep” stands for “global regular expression print".

Detailed explanation-5: -The grep filter searches a file for a particular pattern of characters, and displays all lines that contain that pattern. The pattern that is searched in the file is referred to as the regular expression (grep stands for global search for regular expression and print out).

There is 1 question to complete.