How can I print existing ASCII art from a Bash script?

Solution 1:

This is the shortest form I was able to produce, that prints exactly that 007 string:

base64 -d <<<"H4sIAJM2MVYAA1NQgAEDIIhHBsgCBmgAU8TAQJsL2SgU41AFiDALYRhUF8I0NAEUCbBZUB7MBGRrUXX
g8DC6CagORwkYtDCDcw3IMwDdOBL1IyRRwpBI7cihTlSYkRRNUHcRnUZgXIQGIlOoOQC/4ufk0gIAAA==" | gunzip

Solution 2:

What about just echo?:

echo -e "              0000_____________0000________0000000000000000__000000000000000000+\n            00000000_________00000000______000000000000000__0000000000000000000+\n           000____000_______000____000_____000_______0000__00______0+\n          000______000_____000______000_____________0000___00______0+\n         0000______0000___0000______0000___________0000_____0_____0+\n         0000______0000___0000______0000__________0000___________0+\n         0000______0000___0000______0000_________000___0000000000+\n         0000______0000___0000______0000________0000+\n          000______000_____000______000________0000+\n           000____000_______000____000_______00000+\n            00000000_________00000000_______0000000+\n              0000_____________0000________000000007;"

Every newline has been replaced with \n to shove it all into one line

enter image description here

It won't resize to the terminal though etc (unless you check the terminal width and echo one that is the right size), and it isn't that short either (is there a way to repeat characters better?) but it should work. If you want the colours as well you can use escape codes:

echo -e "\033[31m           0000\033[0m_____________0000________0000000000000000__000000000000000000+\n\033[31m         00000000\033[0m_________00000000______000000000000000__0000000000000000000+\n\033[31m        000\033[0m____000_______000____000_____000_______0000__00______0+\n\033[31m       000\033[0m______000_____000______000_____________0000___00______0+\n\033[31m      0000\033[0m______0000___0000______0000___________0000_____0_____0+\n\033[31m      0000\033[0m______0000___0000______0000__________0000___________0+\n\033[31m      0000\033[0m______0000___0000______0000_________000___0000000000+\n\033[31m      0000\033[0m______0000___0000______0000________0000+\n\033[31m       000\033[0m______000_____000______000________0000+\n\033[31m        000\033[0m____000_______000____000_______00000+\n\033[31m         00000000\033[0m_________00000000_______0000000+\n\033[31m           0000\033[0m_____________0000________000000007;"

enter image description here

By the way you may want to consider copyright and boring stuff depending onhow you are using it - e.g. this version which is similar seems to still be in copyright.

Solution 3:

Put the characters in a file and cat it.

cat 007.txt

Use a "here document"

cat <<EOF
      0000_____________0000________0000000000000000__000000000000000000+
    00000000_________00000000______000000000000000__0000000000000000000+
    . . .
EOF

echo a string with embedded newlines

echo '          0000_____________0000________0000000000000000__000000000000000000+
    00000000_________00000000______000000000000000__0000000000000000000+
    . . .'

The advantage of these approaches is that the art is still readable.

Solution 4:

Shamefully borrowing ( aka stealing ) B.Roland's answer , I suggest a package with a colorfull name . . . toilet ! Which you can get with sudo apt-get install toilet and it works roughly like this:

xieerqi:$ toilet 007

  mmmm   mmmm  mmmmmm
 m"  "m m"  "m     #"
 #  m # #  m #    m" 
 #    # #    #   m"  
  #mm#   #mm#   m" 

It also supports changing fonts ( located in /usr/share/figlet )

 toilet -f bigascii12  LINUX                                                                                 



 ##         ######   ###   ##  ##    ##  ##    ## 
 ##         ######   ###   ##  ##    ##  :##  ##: 
 ##           ##     ###:  ##  ##    ##   ##  ##  
 ##           ##     ####  ##  ##    ##   :####:  
 ##           ##     ##:#: ##  ##    ##    ####   
 ##           ##     ## ## ##  ##    ##    :##:   
 ##           ##     ## ## ##  ##    ##    :##:   
 ##           ##     ## :#:##  ##    ##    ####   
 ##           ##     ##  ####  ##    ##   :####:  
 ##           ##     ##  :###  ##    ##   ##::##  
 ########   ######   ##   ###  :######:  :##  ##: 
 ########   ######   ##   ###   :####:   ##    ##