715
edits
Changes
→LINUX PRACTICE QUESTIONS
= LINUX PRACTICE QUESTIONS =
== REVIEW QUESTIONS: SIMPLE & COMPLEX REGULAR EXPRESSIONS ==
Here is a link to the [https://matrix.senecacollege.ca/~osl640/questions/osl640_command_practice_9a.docx MS Word Document of ALL of the questions] displayed below but with extra room to answer on the document to simulate a quiz.
13. Write a Linux command to display all lines in the file called '''~/text.txt''' that contains exactly 3 numbers.<br>
14. Write a Linux command to display all lines in the file called '''~/text.txt''' that contains 1 or more “C” characters.<br>
== REVIEW QUESTIONS: REGULAR EXPRESSIONS (INCLUDING EXTENDED REGULAR EXPRESSIONS) ==
Here is a link to the [https://matrix.senecacollege.ca/~osl640/questions/osl640_command_practice_9B.docx MS Word Document of ALL of the questions] displayed below but with extra room to answer on the document to simulate a quiz.
Your instructor may take-up these questions during class. It is up to the student to attend classes in order to obtain the answers to the following questions. Your instructor will NOT provide these answers in any other form (eg. e-mail, etc).
'''Part A: Display Results from Linux Commands using Regular Expressions'''
Note the contents from the following tab-delimited file called '''~murray.saul/uli101/numbers.txt''':
<pre>
+123
---34
+++++++++++17
-45
45p8
25.6
11
</pre>
Write the results of each of the following Linux commands using regular expressions for the above-mentioned file.
1. <span style="font-family:courier;font-weight:bold">grep "^[-+]" ~murray.saul/uli101/numbers.txt</span><br>
2. <span style="font-family:courier;font-weight:bold">grep "^[-+]*.[0-9]" ~murray.saul/uli101/numbers.txt</span><br>
3. <span style="font-family:courier;font-weight:bold">grep "^[+-]?[0-9]" ~murray.saul/uli101/numbers.txt</span><br> (Why?)<br>
4. <span style="font-family:courier;font-weight:bold">egrep "^[+-]?[0-9]" ~murray.saul/uli101/numbers.txt</span><br>
5. <span style="font-family:courier;font-weight:bold">egrep "^[+-]?[0-9]+$" ~murray.saul/uli101/numbers.txt</span><br>
6. <span style="font-family:courier;font-weight:bold">egrep "^[+-]?[0-9]+[.]?[0-9]+$" ~murray.saul/uli101/numbers.txt</span><br>
'''Part B: Writing Linux Commands Using Regular Expressions'''
Write a single Linux command to perform the specified tasks for each of the following questions.
7. Write a Linux command to display all lines in the file called '''~/data.txt''' that begins with 1 or more occurrences of an UPPERCASE letter.
8. Write a Linux command to display all lines in the file called '''~/data.txt''' that ends with 3 or more occurrences of the number 6
9. Write a Linux command to display all lines in the file called '''~/data.txt''' that begins with 2 or more occurrences of the word “the” (upper or lower case).
10. Write a Linux command to display all lines in the file called '''~/data.txt''' that begins with 2 or more occurrences<br> of the word “the” <u>or</u> the word “but” (upper or lower case).
11. Write a Linux command to display all lines in the file called '''~/data.txt''' that begins with a minimum of 2 occurrences<br> and a maximum of 4 occurrences of the word “the” or the word “but” (upper or lower case).
[[Category:OSL640]]