grep \'a*\' b? searches for 0 or more a\'s in two character file names that begi
ID: 3910777 • Letter: G
Question
grep 'a*' b?
searches for 0 or more a's in two character file names that begin with b
Write a regular expression that will find all lines in a file named meetingMinutes that end in a question mark '?'
'?^'
What is the output of the following?
cat finalFile
1
12
123
1234
12345
bash-3.2$ grep '....' finalFile | wc -l
1
Which regular expression will find all lines in the file termApplications that contain valid birth month in the form: 1 letter month abbreviation followed by a 2 digit year, where the month abbreviation can only be: a, d, f, j, m , n, o, or s.
(So a97 and J04 would match, but not t45)
[adfjmnosADFJMNOS,0-9,0-9]
searches lines starting with a, in files that begin with bExplanation / Answer
Ans:
Q.2
option B - '?$'
Explanation:
grep '?$' command will print all the lines that end with '?'
The Regular expression $ will print all the lines that end with the input character or string
Example:
grep 's$'
output: All the lines that end with the character 's'
grep 'ing$'
output: All the lines that end with the string 'ing'
Q.3
option B - 2
Explanation:
-The regular expression '.' (dot) matches any character in place of it.
-If there are two dots, then grep command matches any two characters in place of it.
-wc command stands for "word count". This command counts the number of lines, words and total bytes
-wc -l command counts the number of lines
- grep '....' finalFile
The above command prints all the lines that contain at least four characters. When this command piped with wc -l prints the number of lines that contains atleast four characters(any).
-In the file f'inalFile' the number of lines that contains four characters are 2.
-They are 1234 and 12345
Example: grep '..' finalFile | wc -l
output: 4
grep '...' finalFile | wc -l
output: 3
please like my answer if you are satisfied with it. thanks!
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.