Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Using Linux Programing language: uestion2 Lists are commonly stored in environment variables by putting a colon between each of the list elements (the value of
Using Linux Programing language:
uestion2 Lists are commonly stored in environment variables by putting a colon between each of the list elements (the value of the PATH variable is an example). You can add an element to such a list by appending the new element to the front of the list, as in PATH-/opt/bin:SPATH If the element you add is already in the list, you now have two copies of it in the list. Write a shell script named advenv that takes two arguments: (1) the name of a shell variable and (2) a string to prepend to the list that is the value of the shell variable only if that string is not already an element of the list. For example, the call addenv PATH /opt/bin would add /opt/bin to PATH only if that pathname is not already in the PATH. Be sure your solution works even if the shell variable starts out empty. If /usr/opt/bin is in PATH but /opt/bin is not, the example just given should still add /opt/bin to PATH. Provide the program output to demonstrate that your script works
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started