1)For instance, find any line that begins with a capital letter and ends with a period uses the following expression:
$ grep "^[A-Z].*\.$" demo.txt
-- 1
what is the difference between grep '^[A-Z].*\.$' demo.txt
and expression 1(using single quotes, I tried it and it seems the same)
what is the difference between grep '^[A-Z]*\.$' demo.txt
and expression 1(what is the period for?)
2)To find each line in the file that contains an opening and closing parenthesis, with only letters and single spaces in between, uses
$ grep "([A-Za-z ]*)" demo.txt
, is there another way to represent the same thing using {}
?
something like $ grep "([A-Za-z ]\{...\})" demo.txt
3)Assume we want to search the contents of a text file called letter.txt, for the number of times a line began with one of these words: DO, DOO, or DOOO. How do we use the grep command(using only a single switch,cannot use them or, and using the single quotes)
I tried something like this grep -c '^D(O){1,3}' letter.txt
it seems not right.