Write a shell script to concatenate lists together

Assignment Help Operating System
Reference no: EM131697162

Assignment

Write a shell script to concatenate lists together, and output the resulting list. Do not include any argument that is a sub-list of the entire list. (The script will clean the list of any redundant items.) You must preserve the original order of the list. Remember to account for the following situations:

• a : at the beginning of the list is the same as a . at the beginning of the "list" (:/bin is the same a .:/bin)
• a :: any where in the list is the same as :.: (/bin::/etc is the same as (/bin:.:/etc)
• a : at the end of the list is the same a :. ( /bin: is the same as /bin:. )
• Project usings temporary files will not be graded.
• The input to the script will be color or space separated lists and the output will be a colon separated list with the orignal order preserved and all redunant items removed.

USAGE: clean_list list ....

Where list a a colon or whitespace separated list.

Examples:
prompt>clean_list a a:b a:b:c :x: y:z
a:b:c:.:x:y:z

prompt>clean_list /bin:/usr/bin:/usr/openwin/bin /usr/bin:/usr/etc:/etc: /usr/bin/X11 .:/bin
/bin:/usr/bin:/usr/openwin/bin:/usr/etc:/etc:.:/usr/bin/X11

prompt>clean_listapple:orange:apple pear orange peach
apple:orange:pear:peach

REMEMBER TO HANDLE THE SPECIAL CASES OF LEADING :, A ::, AND A TRAILING :

• Example Script very similar to Project 2

The following script is very similar to project 2; however, the major differences are is that it works with a single variable, not the command line arguments and the script tests to see if directories exist (not needed for project 2). Also, for project 2, each positional parameter, can be a special case, where : at the begining of a paramter is really .:, a :: in a parameter is really :.:, and a : at the end of a parameter is :.

You should run this script and see what happens and then modify it to meet the requirements for project 2

That is the tricky part, becase A:B :C --> is A:B:.:C but the code below won't handle that case.
#!/bin/sh
NP=
for P in `echo $PATH | sed -e 's/^:/.:/' -e 's/::/:.:/' -e 's/:$/:./' -e 's/:/ /g'`
do
case $NP in
"")
if [ -d "$P" ]
then
NP="$P"
fi
;;
$P|$P:*|*:$P:*|*:$P)
continue
;;
*)
if [ -d "$P" ]
then
NP="$NP:$P"
fi
;;
esac
done
echo $NP

Attachment:- Linux-Assignment.zip

Reference no: EM131697162

Questions Cloud

Design a study to investigate the impact of new environment : Migrating to a new environment can affect our access to food, health care services and other resources. Design a study to investigate the impact of environment
Price of the company stock today : The company's cost of equity (rs) is 9%. Using the dividend growth model (allowing for nonconstant growth), what should be the price of the company's stock.
Compute the number of bars needed for the wall : Determine the number of 20-foot-long #4 bars needed for the wall in Problem if the wall is horizontally reinforced by bond beams at 4 feet on center.
What is the bond coupon rate : The bond has 10 years to maturity, pays interest semiannually, and has a yield to maturity of 9%. What is the bond's coupon rate?
Write a shell script to concatenate lists together : Write a shell script to concatenate lists together, and output the resulting list. Do not include any argument that is a sub-list of the entire list.
Different exposures to interest rate risk : "Two investors holding the same bond (or bond portfolio) can have different exposures to interest rate risk if they have different investment horizons".
Bonds to raise the needed funds : Vandelay Industries needs to raise $50,000,000 by selling bonds. The bonds have a par value of $1,000, pay coupon interest semi-annually
Display only a list of files where file name starts with os : Display ONLY a list of files where the file name starts with OS. Move up one level in the directory from the F1 folder in the Lab10Folder.
Required rate of return on pepperazzi stock : The required rate of return on Pepperazzi's stock is 18%. The stock should sell for $____ today (that is, at t = 0).

Reviews

Write a Review

Operating System Questions & Answers

  Implementation of algorithms for process management

The Shortest Job Next (SJN) algorithm queues processes in a way that the ones that use the shortest CPU cycle will be selected for running rst.

  Develop a user mode command interpreter

Develop a user mode command interpreter which support list-short.

  Memory allocation in operating system

Analysis and implementation of algorithms for memory allocation in operating system, Explain First- t and best- t methods are used in memory allocation in operating systems.

  Stand alone child process

Forking the child process

  Write a multi-threaded program

Write a multi-threaded program to solve producer and consumer problem

  Marginal and average cost curves

n a competitive market place (pure competition) is it possible to continually sell your product at a price above the average cost of production.

  Simulating operating systems scheduling

Simulate the long-term scheduler, the short-term scheduler and the I/O scheduler of the computer using the First-Come-First-Serve algorithm.

  Issues with trusted platform module

Research paper discussing the issues with Trusted Platform Module (TPM)

  Threads

Explain a complication that concurrent processing adds to an operating system.

  Design and programming

Use the semaphore methods to control the concurrency of the solution

  Virtual machines

Virtual machines supported by a host operating system

  Discuss an application that benefits barrier synchronization

Discuss an application that would benefit from the use of barrier synchronization

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd