Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

a)What are the grep and egrep commands used for, and what is the difference betw

ID: 3816498 • Letter: A

Question

a)What are the grep and egrep commands used for, and what is the difference between them?

b) Give the command to search the file ‘idioms.txt’ for all lines beginning with ‘When’ or ‘Why’ or ‘How’.

c) Why are regular expressions useful in Unix?

d) Give regular expressions (such that could be used with grep and egrep) for each of the following:

- All lines ending with the phrase ‘here below’ - All lines that end in either ‘y’ or ‘z’

- All lines that contain the word ‘index’ followed by any odd number/digit followed by any even number/digit (ignore 0’s)

- All lines that contain either 0 or 1 instances of the character ‘R’, but no more

- All lines that contain a word with 1 or more of the letter ‘a’, followed by 0 or 1 of the letter ‘b’, followed by the letter ‘c’

Explanation / Answer

(a)In unix-file system which can be used to search for anything
whether it be a file,or a line or multiple lines in the file is grep utility.
For extending purpose of GREP is called as egrep(extended grep).

(b)$ cat < idioms.txt > idioms.txt.bak

c)regular expressions are

vi
sed
grep
csplit
dbx
dbxtool
more
ed
expr

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote