i have a different type of trivia question text file now and am unsure how to modify the script i have to place it in the correct format i need. this is the script im trying to modify
#!/bin/bash
FILENAME="trivia1.txt"
while read string
do
# Start of line parsing.
echo $string # Prints out the string.
i=`expr index "$string" :` # Obtain index of :
# Extracts a substring of position x and position x + 1, or the letter at position x
# Checks if equal to a colon.
answer=${string:0:$((i-1))} # Obtains everything before the colon
question=${string:$i} # Obtains everything after the colon
question=${question%?} # Remove the newline
echo "$answer"
echo "$question"
result=`echo $question*$answer`
echo $result
echo $result >> ./result.txt
done < $FILENAME # Reads the file.
echo ""
echo "File conversion has finished. Check result.txt in this directory."
echo "Press enter to exit"
read enter # Just a goodie, no need to remember this
this is the format of the txt file i need to modify
Category: Architectural terms
Question: A bell tower, usually not actually attached to a church.*
Answer: campanile
Category: Architectural terms
Question: A continuous aisle in a building, especially around the apse in a church.*
Answer: ambulatory
Category: Architectural terms
Question: A curved structure used to span an opening.*
Answer: arch
Category: Architectural terms
Question: A curved triangle at the corners of a square or polygonal room, used at the opening of a dome.*
Answer: pendentive
this is the format i need the them in
Category: Architectural terms : Question: A bell tower, usually not actually attached to a church.*campanile
Category: Architectural terms : Question: A continuous aisle in a building, especially around the apse in a church.*ambulatory
Category: Architectural terms : Question: A curved structure used to span an opening.*arch
Category: Architectural terms : Question: A curved triangle at the corners of a square or polygonal room, used at the opening of a dome.*pendentive
in the original text file it places an asterisk after all periods and question marks. i was wodnering if there was a way to just remove the spaces and backspace the line with Answer: so that its right after the question. that way i can just use search and replace in gedit to first remove all asterisks then replace Answer: with *
if you need any more info ask me please...and thanks in advance for any help offered



