无法使ASCII艺术作品回显到控制台 [英] Can't get ASCII art to echo to console

查看:73
本文介绍了无法使ASCII艺术作品回显到控制台的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Bash脚本的新手,这对我来说很令人困惑.我在项目中添加了ASCII艺术,似乎无法弄清楚如何转义某些字符.有人可以帮我下面的代码工作吗?

I'm new to Bash scripting, and this here is just puzzling to me. I'm adding ASCII art to a project, and can't seem to figure out how to escape certain characters. Would someone please help me get the following code below to work?

每当我尝试添加斜杠作为转义字符以修复错误时,这些斜杠还会使打印在执行时集中到控制台.这会破坏图像.我不明白自己在做什么错,所以我在下面发布了代码,希望有人花点时间向我展示正确的方法.请? 我删除了引号,以防止混乱.

Whenever I tried adding slashes as escape characters to fix the errors, the slashes also wound up printing to console on execution. This ruins the image. I don't understand what I'm doing wrong, so I've posted the code below in the hopes that someone will take a moment to show me the right way. Please? I've removed the quotes to prevent more clutter.

echo -en "\E[31m"
echo
echo       _,.
echo     ,` -.)
echo    '( _/'-\\-.              
echo   /,|`--._,-^|          ,    
echo   \_| |`-._/||          ,'|      
echo     |  `-, / |         /  /     
echo     |     || |        /  /      
echo      `r-._||/   __   /  / 
echo  __,-<_     )`-/  `./  /
echo '  \   `---'   \   /  /
echo     |           |./  / 
echo     /           //  /    
echo \_/' \         |/  /        
echo  |    |   _,^-'/  /             
echo  |    , ``  (\/  /_       
echo   \,.->._    \X-=/^        
echo   (  /   `-._//^` 
echo    `Y-.____(__}             
echo     |     {__)          
echo           ()`    

推荐答案

bash中的行情是重要的语法元素,而不是混乱的东西.但是,要打印ASCII艺术作品,请避免使用正确的引号和转义符的麻烦,只需使用here document:

Quotes in bash are important syntactic elements, not clutter. However, to print ASCII art, save yourself the trouble of proper quoting and escaping and just use a here document:

cat << "EOF"
       _,.
     ,` -.)
    '( _/'-\\-.               
   /,|`--._,-^|            ,     
   \_| |`-._/||          ,'|       
     |  `-, / |         /  /      
     |     || |        /  /       
      `r-._||/   __   /  /  
  __,-<_     )`-/  `./  /
 '  \   `---'   \   /  / 
     |           |./  /  
     /           //  /     
 \_/' \         |/  /         
  |    |   _,^-'/  /              
  |    , ``  (\/  /_        
   \,.->._    \X-=/^         
   (  /   `-._//^`  
    `Y-.____(__}              
     |     {__)           
           ()`     
EOF

确保不要在此处删除引号.它们不是可选的.

Make sure not to remove the quotes here. They are not optional.

这篇关于无法使ASCII艺术作品回显到控制台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆