QuestionQuestion

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 PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse 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...
$90.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Linux Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats