Introduction
In this challenge, you'll create a simple file system explorer script that demonstrates your understanding of basic file and directory operations in shell scripting. You'll use file tests to check for existence, type, and permissions of files and directories.
Create the File System Explorer Script
Tasks
- Navigate to the
~/projectdirectory where you'll find a partially completed script namedfile_explorer.sh. - Open the
file_explorer.shfile and complete thecheck_itemfunction to explore file system items.
Requirements
- The script
file_explorer.shis already created in the~/projectdirectory with a basic structure. - Your task is to complete the
check_itemfunction:- It should take one parameter (the name of a file or directory).
- It should perform the following checks and echo the results:
- If the item exists
- If it's a file or a directory
- If it's readable
- Use appropriate file test operators (
-e,-f,-d,-r) for each check.
- The main part of the script (which calls the function) is already provided.
Example
Here's an example of how the completed script should work:
$ ./file_explorer.sh test_file.txt
Checking: test_file.txt
Exists: Yes
Type: File
Readable: Yes
$ ./file_explorer.sh non_existent.txt
Checking: non_existent.txt
Exists: No
$ ./file_explorer.sh test_directory
Checking: test_directory
Exists: Yes
Type: Directory
Readable: Yes
Summary
In this challenge, you created a simple file system explorer script using shell scripting. You practiced using file test operators to check for the existence, type, and permissions of files and directories. This exercise reinforced your understanding of basic file system operations in shell scripts, demonstrating practical applications for file and directory management tasks.



