1. The Shell We'll be doing a fair bit of work on the command line this trimester, so the first part of this assignment is to learn about the UNIX/Linux shell. There's a very good treatment of the shell in MIT's [_The Missing Semester of Your CS Education_](https://missing.csail.mit.edu/) lecture series and the first task is to read 1. 1. and to complete a couple of simple exercises. There are lecture videos from the MIT course, available on YouTube and embedded in the web page, but viewing the lecture videos is _optional_. Complete the following simple exercises: 1. In the fenced code block below, paste the one-line command and output which will list the [shebang](https://en.wikipedia.org/wiki/Shebang_(Unix)) (`#!`) line (if present) of all the (`*.py`) files in your repository. The output should be 8-lines in length. **Hint** use `find` to find the files and execute `grep` on the list of files to select the shebang line(s) from the files.    **Answer:**    ```shell    $        ``` 2. The data recorder output log looks like:    ```text      2023-02-09 16:00:08  DEBUG  main: machine.wake_reason(): 0    2023-02-09 16:00:08  DEBUG  main: machine.reset_cause(): 3    2023-02-09 16:00:08  INFO   main: Entering Regular Mode    ...    2023-02-09 16:00:22  INFO   main: Entering deep sleep for 578 s (9.6 minutes)    2023-02-09 16:10:08  DEBUG  main: machine.wake_reason(): 4    2023-02-09 16:10:08  DEBUG  main: machine.reset_cause(): 4    2023-02-09 16:10:08  INFO   main: Entering Regular Mode    ...    2023-02-09 16:10:22  INFO   main: Entering deep sleep for 578 s (9.6 minutes)    ...    2023-02-09 16:10:08  DEBUG  main: machine.wake_reason(): 4    2023-02-09 16:10:08  DEBUG  main: machine.reset_cause(): 4    2023-02-09 16:10:08  INFO   main: Entering Regular Mode    ```    Let's say we need to analyse the occurrence of the different wake reasons. What is the `grep` command to show just the text `machine.wake_reason() ...`? You might find it helpful to save the sample log above to a file to test. **Hint:** read the manual page (`man grep`) to find the flag to only show the matching text and use the short regular expression `.*` in your `grep` match string to match any string of characters.        **Answer:** `` 3. Log analysis with `grep` can generate lots of lines, potentially 10's of thousands. The commands `sort` and `uniq -c` (see `man uniq` for details of this command and its flag) can help with the analysis, but how would you connect the output of `grep` to the input of `sort` and the output of `sort` to the input of `uniq -c`?

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
1. The Shell

We'll be doing a fair bit of work on the command line this trimester, so the first part of this assignment is to learn about the UNIX/Linux shell.

There's a very good treatment of the shell in MIT's [_The Missing Semester of Your CS Education_](https://missing.csail.mit.edu/) lecture series and the first task is to read

1. <https://missing.csail.mit.edu/2020/course-shell/>
1. <https://missing.csail.mit.edu/2020/shell-tools/>

and to complete a couple of simple exercises. There are lecture videos from the MIT course, available on YouTube and embedded in the web page, but viewing the lecture videos is _optional_.

Complete the following simple exercises:

1. In the fenced code block below, paste the one-line command and output which will list the [shebang](https://en.wikipedia.org/wiki/Shebang_(Unix)) (`#!`) line (if present) of all the (`*.py`) files in your repository. The output should be 8-lines in length. **Hint** use `find` to find the files and execute `grep` on the list of files to select the shebang line(s) from the files.

   **Answer:**

   ```shell
   $ <insert command here>
   <insert output here>
   ```

2. The data recorder output log looks like:

   ```text  
   2023-02-09 16:00:08  DEBUG  main: machine.wake_reason(): 0
   2023-02-09 16:00:08  DEBUG  main: machine.reset_cause(): 3
   2023-02-09 16:00:08  INFO   main: Entering Regular Mode
   ...
   2023-02-09 16:00:22  INFO   main: Entering deep sleep for 578 s (9.6 minutes)
   2023-02-09 16:10:08  DEBUG  main: machine.wake_reason(): 4
   2023-02-09 16:10:08  DEBUG  main: machine.reset_cause(): 4
   2023-02-09 16:10:08  INFO   main: Entering Regular Mode
   ...
   2023-02-09 16:10:22  INFO   main: Entering deep sleep for 578 s (9.6 minutes)
   ...
   2023-02-09 16:10:08  DEBUG  main: machine.wake_reason(): 4
   2023-02-09 16:10:08  DEBUG  main: machine.reset_cause(): 4
   2023-02-09 16:10:08  INFO   main: Entering Regular Mode
   ```

   Let's say we need to analyse the occurrence of the different wake reasons. What is the `grep` command to show just the text `machine.wake_reason() ...`? You might find it helpful to save the sample log above to a file to test. **Hint:** read the manual page (`man grep`) to find the flag to only show the matching text and use the short regular expression `.*` in your `grep` match string to match any string of characters.
   
   **Answer:** `<insert command here>`

3. Log analysis with `grep` can generate lots of lines, potentially 10's of thousands. The commands `sort` and `uniq -c` (see `man uniq` for details of this command and its flag) can help with the analysis, but how would you connect the output of `grep` to the input of `sort` and the output of `sort` to the input of `uniq -c`?

   **Answer:** ...
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Linux
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education