Question
(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
(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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started