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 is difference between file descriptor and file pointer?

How can an index file be used to speed up the access in direct-access files? Have an index in memory; the index gives the key and the disk location of its corresponding record.

how to solve queing theory step by step

Write a XML with database with book details (BOOK ID, Title, Author, subject, publisher year, language, vendor, and price)

Developing an application for android encompass different steps as follows: Setup:  Development environment is prepared during this phase. This includes downloading and installi

Smith, who is a civil engineer, purchased a 30-hectare block of land in Australia in 1986 and used two hectares of it as a main residence. The part that was not main residence cost

Concept of Reentrancy   It is a useful, memory-saving method for multiprogrammed timesharing machines. A Reentrant method is one in which multiple clients can share a singl

Q. Does Windows XP offer any user-mode processes that enable it to run programs developed for other operating systems? Describe two of these subsystems. Answer: Environmental

Describe paging technique used in UNIX systems. When a process begin in UNIX, not every its memory pages are read in from the disk at once. In its place, the kernel loads into

What is ERD? Entity Relationship Diagram is the graphical representation of the object relationship pair. It is mostly used in database applications.