Introduction
As a junior system administrator, you've been tasked with creating a simple report on the directories in your Linux system's PATH. This task will help you understand the structure of the PATH variable and practice using basic command sequences and pipelines.
Create the PATH Analysis Script
Your task is to create a script named path_analysis.sh that processes the $PATH variable and reports on the directories it contains.
Tasks
- Create a script named
path_analysis.shin the~/projectdirectory. If the script already exists, you can modify it. - Use command sequences and pipelines to:
- Display the full PATH.
- List each directory in the PATH on a separate line.
- Count the total number of directories in the PATH.
- Format the output as shown in the example below.
Requirements
Your script must meet these requirements:
- Use only command sequences (
&&,||) and pipelines (|) for control flow. - Utilize basic commands like
echo,tr,wc, andgrepfor text processing. - Format the output to match the example below.
Hits
- The
path_analysis.shfile for editing is located in the~/projectdirectory in the left side directory tree. - Open a new terminal window from the top Terminal menu to run the script file with the
bashcommand.

Example
Your script's output should resemble this format:

Full PATH:
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
Directories in PATH:
/usr/local/sbin
/usr/local/bin
/usr/sbin
/usr/bin
/sbin
/bin
Total directories in PATH: 6
Summary
By completing this challenge, you've demonstrated your ability to:
- Process environment variables using basic command sequences and pipelines.
- Combine multiple Unix commands to analyze and present data.
- Format and present data in a structured output.
This exercise introduces you to processing system variables, a common task in system administration. The skills you've practiced are fundamental to shell scripting and command-line data processing in Unix-like systems.



