PrepAway - Latest Free Exam Questions & Answers

Which command would you use?

You want to search the file myfile for all occurances of string containing at least five characters,
where character number 2 and 5 are ‘a’ and character number 3 is NOT ‘b’.

Which command would you use?

PrepAway - Latest Free Exam Questions & Answers

A.
grep a*^b*a myfile

B.
grep .a[^b].a myfile

C.
grep .[a].*.[a] myfile

D.
grep .a*^b..a myfile

Explanation:
A) since ^ without brackets indicates beginning of line, this regex would search for lines where any count of ‘a’ come before the start of the line
C) would find every combination like xabax
D) has the same problem as A


Leave a Reply