I did this on top of my .bashrc
.bashrc
vm_name=$(curl http://artii.herokuapp.com/make?text=saml)
echo -e \"
$vm_name
\"
\[\] _
| |
___ __ _ _ __ ___ | |
/ __|/ _ _ \| |
\__ \ (_| | | | | | | |
|___/\__,_|_| |_| |_|_|
\[\]
I got this error
-bash: command substitution: line 9: syntax error near unexpected token
|' -bash: command substitution: line 9:
|' -bash: command substitution: line 9:
| '_ '
Is there a way to bypass this error and force my echo to treat my banner as string ?
While you have found a solution to your problem, it is worth explaining your problem. By escaping the double quotes, you prevent them from being parsed as syntactic quotes (they are interpreted as literal quotes).
Therefore, you are not echoing $vm_name
preceded and followed by empty lines : you are actually echoing "
, having empty command lines (doing nothing), and then trying to execute the content of vm_name
expanded, subject to word splitting, and then seen as a command followed by arguments (which understandably fails).
The following would have worked :
vm_name=$(curl http://artii.herokuapp.com/make?text=saml)
echo -e "
$vm_name
"
Of course, just executing the curl
command without capturing it in a variable is simpler.
Just remember escaped double quotes are not interpreted as string delimiters, they are literal double quotes.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.