I have the following command saved in mat.txt file:
printf "
_ ____ __ _
_ __ (_)_ __/ ___|_ __ __ _ / _| |_
| '_ \| \ \/ / | | '__/ _` | |_| __|
| | | | |> <| |___| | | (_| | _| |_
|_| |_|_/_/\_\\____|_| \__,_|_| \__|
"
when I execute this file after made it executable using:
chmod +x mat.txt
It gives me an Error:
It's saying like command not found, file end reached when searching for ' & syntaxerror.
Anyone knows why?
From
man bash
:In other words,
" ... "
is not sufficient to protect the unbalanced backtick on line 4 of your text; the shell is interpreting it as the start of a command substitution.OTOH you can't use single quotes, because your text contains single quotes.
I'd suggest avoiding the issue of quoting altogether by using a here document. You should also use a shebang to make sure your file is interpreted by the intended shell. So:
then
You didn't ask for a specific interpreter in your question. Therefore, Python(which allows assigning a multi-line string to a variable using triple quotes be it single
''' ... '''
or double""" ... """
) might be an option like so:Which executes like so: