Skip to main content

Command Palette

Search for a command to run...

#TWSBashBlazeChallenge - Day 6

Published
•3 min read•View as Markdown

Challenge 1: The Mysterious Script

Challenge Overview

  • Explore the Script

  • Run the Script

  • Debugging and Decoding

  • Identify the Objective

  • Add Comments and Explanation

  • Optimize (Optional)

  • Present Your Findings

Solution

This script replaces certain set of alphabets with another set of alphabets and reverses the order to make it a secret file. It then reverses and replaces the alphabets and files for a multiple random times before saving it to the final output file.

Challenge 2: The Hungry Bash - Restaurant Order System

Challenge Description

In this challenge, you will be working on a Bash-based restaurant order system. The provided script, restaurant_order.sh, is partially broken and missing some crucial parts. Your task is to fix and complete the script to create a fully functional restaurant order system.

The Broken Script

The restaurant_order.sh script is provided to you, but some essential parts are missing or not functioning correctly. Here are the broken parts:

  1. Missing Menu Display: The script is missing the code to read and display the menu from the menu.txt file. You need to implement the function to read the menu and display it to the customers.

  2. Invalid User Input Handling: The script is not handling invalid user input, such as entering a non-existent item number or negative quantities. You need to implement error handling to prompt users for valid inputs when necessary.

  3. Total Bill Calculation: The script is not calculating the correct total bill based on the customer's order. You need to implement the function to calculate the total bill accurately.

Your mission is to complete the restaurant_order.sh script and make it fully functional. Once you fix all the broken parts, the script should provide a smooth dining experience for our customers.

Solution

The "Recursive Directory Search" challenge is part of the day-6. In this challenge, participants are tasked with creating a Bash script that performs a recursive search for a specific file within a given directory and its subdirectories. The script provided for this challenge is not functioning correctly, and participants must fix and improve it to achieve the desired behavior.

Challenge Details

Objective: Your goal is to fix the provided Bash script, recursive_search.sh, and ensure it performs the recursive search as described below:

  • The script should take two command-line arguments: the directory to start the search and the target file name to find.

  • The search should be recursive, meaning it should look for the target file not only in the specified directory but also in all its subdirectories and their subdirectories, and so on.

  • When the target file is found, the script should print the absolute path of the file and then exit.

  • Proper error handling should be in place to handle cases where the directory does not exist or the target file is not found.

Provided Files:

  1. recursive_search.sh: The main script file that requires fixing and improvement.

Example Usage:

./recursive_search.sh test_files target.txt

If the target file target.txt exists within any of the subdirectories of test_files, the script should print the absolute path of the file. Otherwise, it should print "File not found: target.txt".

Solution

Thankyou!

More from this blog

Untitled Publication

40 posts