Question: (Q2) Practice: Grep (10 marks) To answer this question, record the sequence of commands you perform using the script command as in Question 2 of
(Q2) Practice: Grep (10 marks) To answer this question, record the sequence of commands you perform using the script command as in Question 2 of the first assignment. To review how to use this command, refer to Question 2 of the first assignment or run man script on bluenose. Record your sequence of commands and their outputs in a file a2q2.log and put this file under subversion control. For each of the following questions, create a single pipeline of commands that produces the desired output. (a) Headlines in HTML documents are marked with
, , . . . , where the number indicates the level of the headline. Construct a pipeline using grep and one additional Unix command (you need to decide which one is right for the job) to count how many headlines my CSCI 2132 course webpage contains. This webpage is stored in the file /users/webhome/nzeh/Teaching/2132/index.html on bluenose. (b) Use ls, grep, and wc to produce a list of all files in the /usr/bin directory on bluenose that are at least 10,000,000 bytes in size. (c) When you type ls at the shell prompt, this executes the /bin/ls program. To decide which program to run when you type ls instead of /bin/ls , the shell searches a number of directories to find a file with name ls. It uses the first such file it finds. These directories are stored in your shells environment variable $PATH. The list of environment variables your shell knows about and their values can be listed using the env command. Use env and grep to list the contents of your $PATH environment variable. Provide the right command line options to grep to ensure you list only the $PATH variable. (d) Find all words in the file /usr/share/dict/linux.words on bluenose that contain 20 or more vowels. (e) Count how many words there are in /usr/share/dict/linux.words that start with a b or p and end in ing.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
