#!/bin/bash # Check if the input file exists if [ ! -f "$1" ]; then echo "The file $1 doesn't exist." exit 1 fi # Create or overwrite quotes.js output_file="quotes-list.js" echo "/* List of quotes */" > "$output_file" echo "const quotes = [" >> "$output_file" # Read each line from quotes.txt and format it while IFS= read -r line do # Escape double quotes in the line line=$(echo "$line" | sed 's/"/\\"/g') echo " \"$line\"," >> "$output_file" done < "$1" # Close the array echo "];" >> "$output_file" echo "The file $output_file was succesfully generated."