0 votes
in Linux by
Explain Regular Expressions and Grep

1 Answer

0 votes
by

Explain Regular Expressions and Grep

Regular Expressions are used to search for data having a particular pattern. Some of the commands used with Regular Patterns are: tr, sed, vi and grep.

Some of the common symbols used in Regular Expressions are:

.   Match any character

^   Match the beginning of the String

$   Match the end of the String

*   Match zero or more characters

  Represents special characters

?   Match exactly one character

Suppose the content of a file is as follows:

list contect - linux interview questions - madanswer.com/linux

If you want to list the entries that start with the character ‘a’, then the command would be:

$ cat linux.txt | grep ^a

grep a - - linux interview questions - madanswer.com/linux

If you want to list the entries that start has the character ‘n’, then the command would be:

$ cat linux.txt | grep n

grep n - linux interview questions - madanswer.com/linux

25

Related questions

0 votes
asked Nov 30, 2023 in Linux by sharadyadav1986
+1 vote
0 votes
asked Aug 17, 2023 in ReactJS by GeorgeBell
...