- Reads the list into memory
- Selects a random entry
- Displays it
- Removes it from both memory and disk
- Exits with an error if the list is missing or empty
Why In-Memory vs Persistent Storage?
- Manipulating data in memory means changes disappear once the script ends.

- Persistent storage (files, databases) retains data between runs.

This script uses Bash 4.0+ for the
mapfile builtin.Key Bash Features
- mapfile -t: Loads lines from a file (or stdin) into an array.

- $RANDOM: Yields a pseudo-random integer between 0 and 32767.

Exit Code Reference
1. Prepare the Data File
Createfood_places.txt with initial entries:
2. Initialize the Script
Createlunch_selector.sh:
3. Load and Validate the Array
Populatelunch_options and ensure it’s not empty:
4. Select and Display a Random Option
Choose a random index, echo it, and remove from the in-memory list:5. Persist the Updated List
Write the remaining entries back tofood_places.txt:
6. Complete Script
Here’s the fulllunch_selector.sh. Don’t forget to make it executable: