Create a shell script to locate executable files

Assignment Help Data Structure & Algorithms
Reference no: EM1380659

Question: Create a shell script to locate executable documents? The script takes a list of document names from the command line and determines which would be executed had these names been given as commands.

The search path should be based only on the user's PATH environment variable. I don't want to use use the Unix which command, the ksh whence (type) command, or the bash type command.
The script should find only the first occurrence of the "file". If the file is not found, the script should print an error message that the file was not found in the user's path. (Both the filename and the users path should be printed.)
If the first parameter is '-a', then the script should print all occurrences of the executable file in the user's path. Again if the file was not on the path, an error message should be displayed.
I also don't want to use temporary files.

The shell variable PATH defines the search path for the directory containing the command. Alternative directory names are separated by a colon (:). The current directory can be specified by two or more adjacent colons, or by a colon at the beginning or end of the path list.
If the command name contains a / then the search path is not used. Otherwise, each directory in the path is searched for an executable file.
usage: mywhich [-a] command ....

For example:

prompt> mywhich ls
/bin/ls

prompt> mywhich -a cc
/bin/cc
/usr/ucb/cc

prompt> mywhich ./mywhich
./mywhich

prompt> mywhich fooblar
fooblar not found

prompt> mywhich ksh sh csh bash
/usr/bin/ksh
/bin/sh
/bin/csh
/usr/local/bin/bash

 

Reference no: EM1380659

Questions Cloud

Illustrate what approach would you have recommended : If you had been IS head at NIBCO, illustrate what approach would you have recommended also explain why.
What is strategically relevant about each of your two : What is "strategically relevant" about each of your two dimensions? The beer industry is comprised of for-profit companies that brew beer anywhere in the world for sale in the United States
Explain differentiation strategies are emphasized in text : Review four components that make up legal astuteness also rank order four components in order of most valuable to managers in today's business climate.
Identify and describe a current situation process of change : Identify and describe a current situation, within your current or former organization, where the challenges of the process of change, due to a competitive global environment
Create a shell script to locate executable files : Create a shell script to locate executable documents? The script takes a list of document names from the command line and determines which would be executed had these names been given as commands.
Explain impact of changes in sales volume on both firms : Assuming these companies compete within same industry also have identical sales; explain impact of changes in sales volume on both firms' profits.
What were some of apple''s biggest successes : Apple Computer: Research how Apple managed to reinvent itself over the years. What were some of Apple's biggest successes and failures? Describe why.
Which is considering expansion into china : which is considering expansion into China. The senior management of UA desires an analysis of the Chinese market from various perspectives, including trends and the impact of trends on business operations in the airline industry.
Question related to bash script : Create a shell script to send a customized mail memo to the users listed on the command line through login name, only if they are currently logged on.

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Implement an open hash table

In this programming assignment you will implement an open hash table and compare the performance of four hash functions using various prime table sizes.

  Use a search tree to find the solution

Explain how will use a search tree to find the solution.

  How to access virtualised applications through unicore

How to access virtualised applications through UNICORE

  Recursive tree algorithms

Write a recursive function to determine if a binary tree is a binary search tree.

  Determine the mean salary as well as the number of salaries

Determine the mean salary as well as the number of salaries.

  Currency conversion development

Currency Conversion Development

  Cloud computing assignment

WSDL service that receives a request for a stock market quote and returns the quote

  Design a gui and implement tic tac toe game in java

Design a GUI and implement Tic Tac Toe game in java

  Recursive implementation of euclids algorithm

Write a recursive implementation of Euclid's algorithm for finding the greatest common divisor (GCD) of two integers

  Data structures for a single algorithm

Data structures for a single algorithm

  Write the selection sort algorithm

Write the selection sort algorithm

  Design of sample and hold amplifiers for 100 msps by using n

The report is divided into four main parts. The introduction about sample, hold amplifier and design, bootstrap switch design followed by simulation results.

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