Simply I need to write
"echo" t${count} = "$"t${count}"
To a text file, including all the So the output would be something like:
echo " t1 = $t1"
With " as they are. So I have tried:
count=1
saveIFS="$IFS"
IFS=$'\n'
array=($(<TEST.txt))
IFS="$saveIFS"
for i in "${array[@]}"
do
echo "echo" t${count} = "$"t${count}""
(( count++ ))
done >> long1.txt
And variations on this such as:
echo "echo" """"" t${count} = "$"t${count}""
But I guess the wrapping in double " is only for variables.
Ideas?
There's actually no wrapping in double quotes for variables, first quote starts, the second quote ends the quoted string. You may however concatenate strings however you want, so "$"t${count}""
will actually be equivalent to "$"t${count}
, beginning with a quoted $-sign, followed by 't', followed by the count-variable.
Back to your question, to get a ", you can either put it in a literal string (surrounded by single quotes), like so echo '"my string"'
, note though that variables are not substituted in literal strings. Or you can escape it, like so echo "\"my string\""
, which will put a literal " in the string, and won't terminate it.
echo "echo \"t${count} = $t${count}\""
You need to escape the doublequote (also dollar sign):
echo "\" t = \$t\""
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With