I'm trying to use bash instead of flash cards for my linux+. I have some testing materials I'm trying to write into a bash script that will ask you a question from the test. It works on almost every question, except a few that explicitly use bash commands within the question, for example:
Code:
What word will complete an if statement in bash such as the following: if [ -x "$file" ]; then echo
$file _____
(Please provide the missing word only)
If I isolate this, I can get it to print with echo:
Code:
#!/bin/bash
echo "What word will complete an if statement in bash such as the following: if [ -x "$file" ]; then echo"
echo "$file _____"
echo "(Please provide the missing word only)"
I copied and pasted those same lines into the case-statement within my testing script, and those same lines don't work anymore!
Code:
./LX0-104_studyguide.sh: line 38: syntax error near unexpected token `then'
./LX0-104_studyguide.sh: line 38: `echo "What word will complete an if statement in bash such as the following: if [-x "$file"]; then echo"'
It looks like it's trying to execute the code within the quotes, but what I don't get is the inconsistent behavior. Why do the same lines work on their own but not within a case-statement?
More importantly, how can I get bash to blindly print code without trying to interpret it?
Thank you.