Question
Using UNIX answer the following question please! Question has 18 short steps. Q5. Commands to study to answer this question: tail, head, cmp, diff, comm,
Using UNIX answer the following question please! Question has 18 short steps.
Q5. 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.
- Display the content of each file, one at a time
- Compare the two files using cmp command
- Find the differences between using diff command
- Sort first file and store the result by redirecting the output to a file as sorted
- 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.
- Compare the two sorted files using comm command
- Display ONLY the bottom 5 lines of the first file
- 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
- Issue appropriate command to display the content of first file removing consecutive duplicate lines
- Create the file hw2before_setting_umask using touch command
- 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
- Create the file hw2after_setting_umask using touch command
- Display the file permissions set on hw2before_setting_umask and hw2after_setting_umask
- 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.
- Issue a grep command on hw2test1 with a name that exists in hw2test1.
- Issue a grep command on hw2test[12] with a name that exists in both files (hw2test1 and hw2test2).
- Issue a grep command on hw2test[12] with a name that does not exist in both files.
- 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
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