shell脚本中打印彩色ASCII艺术字生成
系统:Ubuntu22.04LTS
1、艺术字生成
网站搜索“ASCII艺术字在线生成”自己找一个,或者直接到我用的https://tooltt.com/art-ascii/,去生成一个。注意:不支持中文输入内容的生成。通过调整字体,找到自己想要的内容。
2、彩色的生成,通过脚本函数来实现,代码如下:
#!/bin/bash
# ↑脚本内容标识
# 设置脚本语言环境为UTF-8
export LANG=en_US.UTF-8
# 设置输出颜色,红、绿、黄、蓝、默认颜色
red='\033[0;31m'
green='\033[0;32m'
yellow='\033[0;33m'
bblue='\033[0;34m'
plain='\033[0m'
# 定义输出颜色函数
red(){ echo -e "\033[31m\033[01m$1\033[0m";}
green(){ echo -e "\033[32m\033[01m$1\033[0m";}
yellow(){ echo -e "\033[33m\033[01m$1\033[0m";}
blue(){ echo -e "\033[36m\033[01m$1\033[0m";}
white(){ echo -e "\033[37m\033[01m$1\033[0m";}
# 定义输出内容函数
show_it(){
clear
green "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo -e " ██████${bblue}╗${plain} ██████${bblue}╗ ${plain} ██${yy34}╗${plain} ██████${red}╗${plain} ██████${red}╗ ${plain}██${red}╗${plain} ██████${yellow}╗ ${plain}██████${yellow}╗ ${plain}██${yellow}╗${plain}"
echo -e " ██${bblue}╔════╝${plain} ██${bblue}╔═══${plain}██${bblue}╗ ${plain} ██${yy34}║${plain} ██${red}╔════╝${plain} ██${red}╔═══${plain}██${red}╗${plain} ${plain}██${red}║ ${plain}██${yellow}╔════╝${plain} ██${yellow}╔═══${plain}██${yellow}╗ ${plain}██${yellow}║${plain}"
echo -e " ██${bblue}║${plain} ███${bblue}╗${plain}██${bblue}║ ${plain}██${bblue}║ ${plain} ██${yy34}║${plain} ██${red}║${plain} ███${red}╗${plain}██${red}║${plain} ██${red}║ ${plain}██${red}║ ${plain}██${yellow}║${plain} ███${yellow}╗${plain}██${yellow}║${plain} ██${yellow}║ ${plain}██${yellow}║${plain}"
echo -e " ██${bblue}║${plain} ██${bblue}║${plain}██${bblue}║ ${plain}██${bblue}║ ${plain} ${yy34}╚═╝${plain} ██${red}║${plain} ██${red}║${plain}██${red}║${plain} ██${red}║ ╚═╝ ${plain}██${yellow}║${plain} ██${plain}║${plain}██${yellow}║${plain} ██${yellow}║ ╚═╝"
echo -e " ${bblue}╚${plain}██████${bblue}╔╝╚${plain}██████${bblue}╔╝ ${plain} ██${yy34}╗${plain} ${red}╚${plain}██████${red}╔╝╚${plain}██████${red}╔╝ ${plain}██${red}╗ ${yellow}╚${plain}██████${yellow}╔╝╚${plain}██████${yellow}╔╝ ${plain} ██${yellow}╗"
echo -e "${bblue} ╚═════╝ ╚═════╝ ${plain} ${yy34}╚═╝ ${red} ╚═════╝ ╚═════╝ ╚═╝ ${yellow}╚═════╝ ╚═════╝ ╚═╝"green "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
}
# 执行输出内容函数show_it
show_it
#把脚本内容保存到/root/output1.sh中
#执行脚本
bash /root/output1.sh
#看到的内容