Course Solutions Uncategorized (Solved) : Exercise 1 Write Shell Script Loops Etc Passwd File One Line Time Prepend Line Line Number Q34222001 . . . .

(Solved) : Exercise 1 Write Shell Script Loops Etc Passwd File One Line Time Prepend Line Line Number Q34222001 . . . .

 

Exercise 1:

Write a shell script that loopsthrough the /etc/passwd file one line at a time. Prepend each linewith a line number followed by a colon and then a space.

Example output:

1: root:x:0:0:root:/root:/bin/bash

2: daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin

3: bin:x:2:2:bin:/bin:/usr/sbin/nologin

4: sys:x:3:3:sys:/dev:/usr/sbin/nologin

Exercise 2:

Write a shell script that asks theuser for the number of lines they would like to display from the/etc/passwd file and display those lines.

Example output:

How many lines of /etc/passwd would you like to see? 3root:x:0:0:root:/root:/bin/bash

daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologinbin:x:2:2:bin:/bin:/usr/sbin/nologin

Exercise 3:

Write a shell script that that allowsa user to select an action from the menu. The actions are to showthe disk usage, show the uptime on

OR

PayPal Gateway not configured

OR

PayPal Gateway not configured

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post