Write a linux script to add name in class list, Operating System

For this exercise I wanted to give you some real-world examples of useful bash scripts. Therefore, you will write a couple of scripts that I actually use in my teaching to automate clerical tasks. To begin, please copy this (ficitious) classlist.txt to your directory, and note that it contains a list of usernames.

bholly

bjones

bscott

dgatton

dhathaway

jbonham

jcroce

jdenver

jhendrix

jjoplin

jmorrison

kcobain

mhutchence

oredding

pcline

rbuchanan

rrhoads

rwaters

svaughan

wwilliams

Write a script called addnames that is to be called as follows, where classlist is the name of the classlist file, and username is a particular student's username.

./addnames classlist username

The script should

1. print a message stating that the name already existed, or

2. add the name to the end of the list.

 Hint: Use a for-loop to process each line in the file. To create a list of lines in the file, remember that you can use any bash construct inside a script that you can use in the terminal window. How would you list the lines of the file in the terminal window? Similarly, how would you append a particular item to the end of an existing file from the terminal window?

Posted Date: 3/20/2013 1:52:45 AM | Location : United States







Related Discussions:- Write a linux script to add name in class list, Assignment Help, Ask Question on Write a linux script to add name in class list, Get Answer, Expert's Help, Write a linux script to add name in class list Discussions

Write discussion on Write a linux script to add name in class list
Your posts are moderated
Related Questions
What are threads? A thread is alike to sequential programs. Single threads have a beginning, sequence and end. At any given point in time during the runtime of the thread there

What is spooling? Spooling overlaps the I/O of single job with the computation of other jobs.

Briefly explain about file system implementation? Several on-disk and in-memory structures are used to execute a file system. On disk, the file system may have information abou

Placement algorithms :calculate where in available real-memory to execute a program. Common functions are next-fit, first-fit, and best-fit. Replacement algorithms :are

Q. Timers could be utilized to compute the current time. Provide a little description of how this could be accomplished. Answer: A program could utilize the following ap

In which page replacement policy Balady’s anomaly occurs? FIFO (First in First Out)

Explain Chaining to Handle Collision Chaining:  One easy scheme is to chain all collisions in lists attached to the suitable slot. This permits an unlimited number of collision

What is super block A partition control block have partitions details, such as the number of blocks in the partition, size of the blocks, free-blocks and free-block pointers an

What is dispatch latency? The time taken by the dispatcher to stop one process and begin another running is known as dispatch latency.

What is a resource-allocation graph? Deadlocks can be explained more precisely in terms of a directed graph called a system resource allocation graph. This graph having of a se