Question: 2 . ( 1 0 points ) Write a BASH shell script that finds a given command on the search path. If the number of

2.(10 points) Write a BASH shell script that finds a given command on the search path. If the number of command line arguments is incorrect, then print a usage message and exit with exit code 1. If found, then display the pathname and exit with exit code 0. If not found, then display an error message and exit with exit code 1. You may not use the which, find, locate or any similar Linux command. You must use conditional tests. You must use the \$PATH environment variable. Hint: use the tr command.
Filename: cmdsearch.sh
Usage: cmdsearch.sh cmd
3.(10 points) Using your solution in Question 1 as an example, write a BASH shell script that takes a regular expression pattern argument and finds all commands on \$PATH that match the given pattern. If the number of command line arguments is incorrect, then print a usage message and exit with exit code 1. If found, then display the pathname and exit with exit code 0. If not found, then display an error message and exit with exit code 1. You may not use the which, find, locate or any similar Linux command. You must use conditional tests. You must use the \$PATH environment variable. Hint: use \(=\sim \).
Filename: cmdfind.sh
Usage: cmdfind.sh pattern
2 . ( 1 0 points ) Write a BASH shell script that

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!