Which symbol will be used with grep command to match the pattern pat at the end of a line? A. ^pat B. $pat C. pat$ D. pat^ E. None of the above

^pat
$pat
pat$
pat^ E. None of the above

The correct answer is C. pat$.

The grep command is used to search for a pattern in a file or set of files. The pattern can be a regular expression, which is a special type of text that can be used to match a variety of patterns.

The $ character is a special character in regular expressions. It matches the end of the line. So, the pattern pat$ will match the pattern pat at the end of a line.

The other options are incorrect. The ^ character matches the beginning of the line. The pat^ pattern would match the pattern pat at the beginning of a line. The pat pattern would match the pattern pat anywhere in a line. The pat pattern would match the pattern pat anywhere in a line, including at the beginning or end of the line.

Exit mobile version