echo "This is some text with color." 二、将上述脚本保存为一个文件,例如 mycolor.sh。 三、在终端中进入保存脚本的目录,使用以下命令赋予该文件执行权限: chmod +x mycolor.sh 四、在终端中运行脚本,使用以下命令: ./mycolor.sh 执行结果如下: This is some text with color. 注意:上述步骤只是基本的...
#Shell Code:# echo 显示带颜色需要使用参数-e # 字颜色:30—–37echo-e"\033[30m 黑色字 \033[0m"echo-e"\033[31m 红色字 \033[0m"echo-e"\033[32m 绿色字 \033[0m"echo-e"\033[33m 黄色字 \033[0m"echo-e"\033[34m 蓝色字 \033[0m"echo-e"\033[35m 紫色字 \033[0m"echo-e"\...
echo "After using #str : ${#str}" echo "Use expr length : $(expr length "$str")" # 该方式不建议使用,因为shellcheck也建议使用第一种方式 echo "Use expr : $(expr "$str" : '.*')" 7.2 索引子串第一次出现的位置 代码语言:txt AI代码解释 # 语法格式 : expr index "$string" '$subst...
read-p"please select a num:"numcase"$num"in1)echo-e"${YELLOW_COLOR} banana ${RES}";;2)echo-e"${RED_COLOR} apple ${RES}";;3)echo-e"${GREEN_COLOR} pear ${RES}";;4)echo-e"${BLUE_COLOR} cherry ${RES}";;*)echo"please input {1|2|3|4}"esac #说明:定义颜色,使用read读...
echo -e "\033[33m\033[01m[ $1 ]\033[0m" } Dev-web-solr [/opt/hexo2] 2016-11-28 17:52:03 root@pts/4 $ cat /root/bin/test.sh#!/usr/bin/env bashsource /root/bin/common green "hello world with green color" blue "hello world with blue color" ...
【转】shell echo 字体颜色,以备忘。(修正中文双引号的问题) 【说明】 echo-e"\033[字背景颜色;文字颜色m字符串\033[0m" 【示例】 echo-e"\033[30m 黑色字 \033[0m"echo-e"\033[31m 红色字 \033[0m"echo-e"\033[32m 绿色字 \033[0m"echo-e"\033[33m 黄色字 \033[0m"echo-e"\033[34m...
cshell Prompt主要由两部分组成, 一个是颜色定义,一个是信息显示。下面我们分别讲讲述这两部分。颜色(ASCII color)所有颜色都以\033[xxxm的形式输写,xxx...
For bash, downloaddist/ColorEcho.bash. For other shells, choose the corresponding file from thedist directory. Source the script in your shell: ../ColorEcho.bash#For bash ReplaceColorEcho.bashwith the appropriate filename for your shell. ...
5"fori in$arr;doecho$idone# 将 $args 的内容当作两个参数传给 lsargs="--sort=time --color...
alias diff = 'colordiff' #7:让 mount 命令的输出更漂亮,更方便人类阅读 alias mount = 'mount |column -t' #8:简化命令以节省时间 # handy short cuts # alias h = 'history' alias j = 'jobs -l' #9:创建一系列新命令 alias path = 'echo -e ${PATH//:/\\n}' ...