SQLite Forum

sqlite3 .shell - conditional executions with `[[ expr ]]` constructs
Login
I have to say that Warren's suggestion makes more sense than what follows here. Nevertheless:

In the sqlite3 shell, this does what you apparently intend:<code>
.output /tmp/furd
.print fin=file1.doc
.print [[ \\"${fin##*.}\\" = \\"doc\\" ]]
.print echo \\"$?\\n${fin##*.}\\"
.print echo \\"$fin\\"
.output stdout
.shell chmod +x /tmp/furd
.shell /bin/bash -c /tmp/furd
.shell rm /tmp/furd
</code>. Note that the backslashes are understood by the sqlite3 shell meta-command scanner to mean "Don't treat the next character specially." Without being escaped, the double-quotes are used to group text and then they vanish from the result.  If I was not too lazy to try it, I might have found a way to do this without a temporary file, but it is too hard to see what is happening that way for my taste.