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 command as in Question 2 of the first assignment. To review

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 a3q2.log. Question (b) asks you to create a file file.txt. Put both a3q2.txt and file.txt under subversion control. (a) Use the commands ls and which (and no other commands) to find out the owner, group, and size of 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 should not 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. (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, if file.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. (c) Use egrep (or grep -E) to find all words in the file /usr/share/dict/linux.words on bluenose that contain the same 3-letter sequence at least three times. For example, one such word matched by the correct regular expression is cha-cha-cha. It contains the 3-letter sequence cha three times. (d) The example of a regular expression for an IP address I gave in class was too permissive because it only checked that each of the four numbers has 13 digits. A valid IP-address is of the form a.b.c.d, where 0 a, b, c, d 255. Provide a regular expression that checks not only that each number 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

Beginning ASP.NET 2.0 And Databases

Authors: John Kauffman, Bradley Millington

1st Edition

0471781347, 978-0471781349

More Books

Students also viewed these Databases questions