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 the advantages and disadvantages of multithreading?  Advantages : Since by multithreading multiple executions are carried out in the same process environment t

What is Multitasking? Multitasking provides power to users by offering them to run multiple applications at once. The applications are loaded into memory and appear to the user

Question: a) Define the term ‘Operating System' and identify two goals of an operating system. b) What do you understand by Symmetric multiprocessing (SMP) and Asymmetr

what are the overall concepts of deadlock

List and discuss the various services provided by the operating system. Program execution - system capability to load a program into memory and to run it. I/O operatio

Problem: (a) Modern operating systems are interrupt driven. If there are no processes to execute, no I/O devices to service, and no users to whom to respond, an operating syste

function of lazy swapper

Question 1 Explain the following with respect to Resource Management in Distributed Systems- Task assignment Approach Load - Balancing Approach Load - Sharing Approach

Suppose we want to program a Web server; we could easily do so without using concurrency, as follows: while(true) wait connection read from socket and parse url look up url cont

File allocation using I nodes. This method is used to decrease the size of the table in the above method. Every file will have an I-node list. Allow a file have 15 pointers a