This assignment will involve you manipulating the text from a passw...

Question
This assignment will involve you manipulating the text from a password file to output a new file with a specific format. The following steps should be used to create the resulting output file:

1)    Write a script that accepts as an input parameter the path/name for an input password file (either /etc/password or the sample provided). Check for the existence and non-zero size of the input file and re-prompt if not correct.

2)    Use the egrep command on an input password file- redirecting the result of the search to passwordfile. Search for the patterns of cm325 and cm315 (or a set of patterns that are available to you) using the colon (:) as the delimiter. The result should be an intermediate file with just the rows with these two users.

3)    Use the cut command with -f to generate a file for columns 1, 5, 6, and 7, naming them logname, comment, home, and shellfile, respectively.

4)    Taking the logname file, edit it by adding 15 spaces to the end of each line. Cut the logname file with the -c option to produce a file that has only 15 columns on each line and redirect the output to a file named loganame15.

5)    Edit the comment file created above- placing at the beginning of each line the following text where ^ is a space: ^is the logname for^.

6)    Edit the home file created above- placing at the beginning of each line the following text: ^whose home directory is^.

7)    Edit the shellfile file created above- placing at the beginning of each line the following text: ^and using the ^.

8)    Continue editing the shellfile file to add at the end of the file the following: ^shell with a period. Finish editing the shellfile file by removing the /usr/bin that appears before the actual type of shell, then expand the name of the shell to a full name (e.g., sh to Bourne Shell or ksh to Korn Shell). See sample output below for an example of the resulting output.

9)    Paste the resulting four files together in order- producing a file named passwordinfo.

10) Add to the passwordinfo file the following four lines at the top of the file, centered: (1) Password File Information, (2) the names of the two patterns searched (can be hard coded), (3) Prepared by your first/last name, and (4) the date formatted to include mm/dd/yyyy at hh:mm:ss. Upload resulting file, as well as the shell script commands that you used.
Solution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references.
Students may use these solutions for personal skill-building and practice.
Unethical use is strictly forbidden.

#!/bin/bash
egrep 'cm(325|315)' passwdsample.txt > apasswordfile
cut -d':' -f1 apasswordfile > logname
cut -d':' -f5 apasswordfile > comment
cut -d':' -f6 apasswordfile > home
cut -d':' -f7 apasswordfile > shellfile
cut -c1-15 logname > loganame15
This is only a preview of the solution.
Please use the purchase button to see the entire solution.
By purchasing this solution you'll be able to access the following files:
Solution.zip
Purchase Solution
$90.00
Google Pay
Amazon
Paypal
Mastercard
Visacard
Discover
Amex
View Available Computer Science Tutors 645 tutors matched
Ionut
(ionut)
Master of Computer Science
Hi! MSc Applied Informatics & Computer Science Engineer. Practical experience in many CS & IT branches.Research work & homework
5/5 (6,805+ sessions)
1 hour avg response
$15-$50 hourly rate
Pranay
(math1983)
Doctor of Philosophy (PhD)
Ph.D. in mathematics and working as an Assistant Professor in University. I can provide help in mathematics, statistics and allied areas.
4.6/5 (6,694+ sessions)
1 hour avg response
$40-$50 hourly rate
Leo
(Leo)
Doctor of Philosophy (PhD)
Hi! I have been a professor in New York and taught in a math department and in an applied math department.
4.9/5 (6,462+ sessions)
2 hours avg response

Similar Homework Solutions