Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

UNIX, help using putty Commands to study to answer this question: tail, head, cmp, diff, comm, uniq, touch, umask, grep, vi, cat, ls, and echo

UNIX, help using putty

Commands to study to answer this question: tail, head, cmp, diff, comm, uniq, touch,

umask, grep, vi, cat, ls, and echo

Two files can be compared using cmp command and diff command depending on requirements.

In order to do this question, create two files with 12 or more names with one name in each line. Make sure that some names in the two files are same and some are different. Ensure that there are few consecutive lines with identical names (duplicate lines) in each file. Also, make sure that some of the names are the same in both files.

Create these two files before issuing the script command to answer this question.

1) Display the content of each file, one at a time

2) Compare the two files using cmp command

3) Find the differences between using diff command

4) Sort first file and store the result by redirecting the output to a file as sorted

5) Sort second file and store the result by redirecting the output to another file as sorted

Two files can also be compared comm command. There are differences between cmp, diff and comm commands. Read about them and understand the differences.

6) Compare the two sorted files using comm command

7) Display ONLY the bottom 5 lines of the first file

8) Display the top few lines of the second file using the default line count, that is, without using any option in the command. Count and find how many lines it displays by default

9) Issue appropriate command to display the content of first file removing consecutive duplicate lines

10) Create the file hw2before_setting_umask using touch command

11) The umask command can be used to set or change the default file permissions to be set when a new file is created. Issue umask 600 command

12) Create the file hw2after_setting_umask using touch command

13) Display the file permissions set on hw2before_setting_umask and hw2after_setting_umask

14) Using echo command answer what permissions were removed for the owner due to the above umask command

The grep command can be used to search for a string in one or more files. When the line with the string is found, it is displayed. Check this by issuing the following grep commands.

15) Issue a grep command on hw2test1 with a name that exists in hw2test1.

16) Issue a grep command on hw2test[12] with a name that exists in both files (hw2test1 and hw2test2).

17) Issue a grep command on hw2test[12] with a name that does not exist in both files.

18) What difference you see between (16) and (17) by Observing the output of above three grep commands

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

Students also viewed these Databases questions