Step 2: Create a Bash script file called YourFirstName__LastName_L4 with a menu that lets you:

View the contents of the music collection file:
this option should display the entire collection

View the cost of the entire collection:
this option should calculate the total cost of the collection and display it. Do not hard-code the cost of the collection, you must have code to calculate it.

Search for all CDs from a particular artist:
this option allows to search the collection given the artist name. Make the search case insensitive. If there is a CD for the given artist name, the CD info should be displayed. If there is not such CD in the collection, then “Nothing is found for the artist specified” message should be displayed.

Search for all CDs purchased on a specific date:
this option allows to search the collection given the date. Make the search case insensitive. If there is a CD for the given date, the CD info should be displayed. If there is not such CD in the collection, then “Nothing is found for the date specified” message should be displayed.

An option to Exit:
this option should confirm whether the user really wants to exit the script and if the confirmation is given then the script should be terminated. Otherwise, the script should continue running

To create the script, please follow the instructions below:

1. Open a terminal and navigate to the directory where you want to create the script file.

2. Type the following command to create the script file:

```bash
touch YourFirstName__LastName_L4.sh
```

3. Open the script file with a text editor, for example, nano:

```bash
nano YourFirstName__LastName_L4.sh
```

4. Paste the following code into the file, replacing `FirstName` and `LastName` with your first and last name:

```bash
#!/bin/bash

function display_collection() {
cat music_collection.txt
}

function calculate_cost() {
awk -F ',' '{ total += $3 } END { printf("The total cost of the collection is: $%.2f\n", total) }' music_collection.txt
}

function search_artist() {
read -p "Enter the name of the artist: " artist_name
artist_name=$(echo "$artist_name" | tr '[:upper:]' '[:lower:]')
found=false

while IFS=',' read -r id title artist cost date; do
if [[ "${artist,,}" == *"$artist_name"* ]]; then
echo "ID: $id, Title: $title, Artist: $artist, Cost: $cost, Date: $date"
found=true
fi
done <music_collection.txt

if [ "$found" = false ]; then
echo "Nothing is found for the artist specified."
fi
}

function search_date() {
read -p "Enter the date (MM/DD/YYYY): " date_search
found=false

while IFS=',' read -r id title artist cost date; do
if [[ "$date" == "$date_search" ]]; then
echo "ID: $id, Title: $title, Artist: $artist, Cost: $cost, Date: $date"
found=true
fi
done <music_collection.txt

if [ "$found" = false ]; then
echo "Nothing is found for the date specified."
fi
}

while true; do
echo -e "\n--- Menu ---"
echo "1. View the contents of the music collection file"
echo "2. View the cost of the entire collection"
echo "3. Search for all CDs from a particular artist"
echo "4. Search for all CDs purchased on a specific date"
echo "5. Exit"

read -p "Enter your choice (1-5): " choice

case $choice in
1)
display_collection
;;
2)
calculate_cost
;;
3)
search_artist
;;
4)
search_date
;;
5)
read -p "Are you sure you want to exit? (y/n): " confirm_exit
if [[ "$confirm_exit" =~ ^[yY]$ ]]; then
exit
fi
;;
*)
echo "Invalid choice. Please try again."
;;
esac
done
```

5. Save the file and exit the text editor (in nano: press `CTRL + X`, then press `Y` and `Enter`).

6. Modify the file permissions to make the script executable:

```bash
chmod +x YourFirstName__LastName_L4.sh
```

7. Run the script:

```bash
./YourFirstName__LastName_L4.sh
```

You should now see the menu and be able to interact with the script.