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

  Create the entity relationship diagram

Create the entity relationship diagram for your project database based on the initial data requirements.

  Question about pointerlists

Whenever the pointer of a list or a tree is manipulated, procedure that performs this operation must be considered to be in a critical section.

  Determine the mean salary as well as the number of salaries

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

  Explain solution to recurrence-appealing to recursion tree

Solve the following recurrence relations by the method of your choiceT(n) = 1 for n = 4 and T(n) =pnT(pn) + n for n > 4. Argue that the solution to the recurrence T(n) = T(n=3) + T(2n=3) + cn is (n lg n) by appealing to the recursion tree.

  Server of local hospital to support remote access

Explain the file system that will be installed in the server of your local hospital to support remote access of data through the hospital's doctors while they are using their mobile equipments such as cellular phones or PDAs.

  Create algorithm to read arbitrary number of data record

Create the algorithm to read arbitrary number of data records, each containing name, age, and code. Code of 1 will indicate female, a code of 2 will indicate male.

  Determine storage required for bfs and dfs

Determine the minimum number of nodes expanded and storage required for BFS and DFS? (Hint: this question asks about the best case performance of BFS and DFS).

  Refresh address counter

A microcomputer memory is built from 64K X 1 DRAM, with DRAM cell array organized into 256 rows. Each row requires being refreshed at least once every four ms, strictly on a periodic basis.

  Ambiguity in proposed algorithm-in representation algorithm

Describe distinction between the ambiguity in proposed algorithm and ambiguity in representation of the algorithm.

  Discussion on data mining techniques

The tax authorities working for many governments are often confronted with challenge of detecting tax evasion and fraud. Suppose you work at income tax department.

  Object oriented approach versus the relational database

Supporters of object oriented databases list many benefits for using the object oriented approach versus the relational one.

  Prepare the initial linked list of students and grades

Write a C program which initially presents menu of choices for the user. Menu must consist of the following choices: Prepare the initial linked list of students and grades.

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