Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

To answer this question, record the sequence of commands you perform using the script commandas in Question 2 of the first assignment. To review how

To answer this question, record the sequence of commands you perform using the script commandas in Question 2 of the first assignment. To review how to use this command, refer to Question 2 ofthe first assignment or run man script on bluenose. Record your sequence of commands and theiroutputs in a file a3q2.log. Question (b) asks you to create a file file.txt. Put both a3q2.txt andfile.txt under subversion control.

  1. (a) Use the commands ls and which (and no other commands) to find out the owner, group, and sizeof the less program. (Be sure to run this on bluenose because it may have different sizes even on two different Linux systems.) You may need to consult the manpage for the which command to learn what it does. Your solution should consist of a single command line, that is, you shouldnot enter one command, press Enter , and then enter another command and press Enter again;

    everything should be typed after the same shell prompt and you should press Enter only once.You need to find a way to pass the output of which to ls as a command line argument.

  2. (b) Create a file file.txt with anywhere between 10 and 20 lines in it. Now provide a single command line that uses the commands cat, wc, and head to display the first half of this file. For example, iffile.txt has 15 lines, you should display the first 7 lines. If it has 16 lines, you should display the first 8 lines. Since you created the file, you know how many lines it has. Thus, if file.txt has 15 lines, you could simply write head -n 7 file.txt. Do not do this. Instead, provide a command line that works correctly no matter how many lines there are in file.txt. You command line will likely consist of multiple commands separated by ;, one that assigns the length of file.txt to a variable, one that divides this variable by two, and one that uses this variable to instruct head how many lines to display.

  3. (c) Use egrep (or grep -E) to find all words in the file /usr/share/dict/linux.words on bluenosethat contain the same 3-letter sequence at least three times. For example, one such word matchedby the correct regular expression is cha-cha-cha. It contains the 3-letter sequence cha threetimes.

  4. (d) The example of a regular expression for an IP address I gave in class was too permissive becauseit only checked that each of the four numbers has 13 digits. A valid IP-address is of the forma.b.c.d, where 0 a, b, c, d 255. Provide a regular expression that checks not only that eachnumber is 13 digits long but that each number is between 0 and 255.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing

Authors: David M. Kroenke

12th Edition International Edition

1292023422, 978-1292023427

More Books

Students also viewed these Databases questions

Question

Choosing Your Topic Researching the Topic

Answered: 1 week ago

Question

The Power of Public Speaking Clarifying the

Answered: 1 week ago