Linux日常——shell彩色进度条
来源:互联网 发布:域名紧急升级 编辑:程序博客网 时间:2024/05/19 06:50
#!/bin/bashstr=""table=("|" "/" "-" "\\")i=0index=0while [ $i -le 100 ]do if [ $i -lt 20 ]; then printf "[\e[1;31m%-100s\e[0m][%d%%][\e[43;46;31m%c\e[0m]\r" "$str" "$i" "${table[$index]}" elif [ $i -lt 40 ]; then printf "[\e[1;33m%-100s\e[0m][%d%%][\e[43;46;31m%c\e[0m]\r" "$str" "$i" "${table[$index]}" elif [ $i -lt 60 ]; then printf "[\e[1;32m%-100s\e[0m][%d%%][\e[43;46;31m%c\e[0m]\r" "$str" "$i" "${table[$index]}" elif [ $i -lt 80 ]; then printf "[\e[1;34m%-100s\e[0m][%d%%][\e[43;46;31m%c\e[0m]\r" "$str" "$i" "${table[$index]}" else printf "[\e[1;35m%-100s\e[0m][%d%%][\e[43;46;31m%c\e[0m]\r" "$str" "$i" "${table[$index]}" fi str+='#' let i++ let index++ let index%=4 usleep 200000doneprintf "\n"
运行结果:
下面附上C语言:
#include<stdio.h>#include<stdio.h>#include<unistd.h>int main(){ int i = 0; char arr[52];//0~50+'\0'=102 arr[0] = 0; const char* labk = "|/-\\|"; while (i <= 50) { printf("[%-50s][%d%%][%c]\r", arr, i, labk[i % 4]); fflush(stdout); arr[i] = '#'; i++; arr[i] = 0; usleep(150000); } printf("\n"); return 0;}
运行结果:
阅读全文
0 0
- Linux日常——shell彩色进度条
- linux之shell彩色进度条
- Linux:shell脚本之彩色进度条
- linux--shell脚本实现一个彩色进度条
- Shell 彩色进度条
- Shell-彩色进度条~
- shell彩色进度条
- shell实现彩色进度条
- shell实现彩色进度条
- Linux--用shell脚本写一个彩色进度条
- LInux:shell 彩色进度条实现(有图有代码有真相!!!)
- linux脚本编程之shell实现彩色进度条
- 在linux下用c和shell编写彩色进度条
- shell编程 实例----彩色进度条
- shell脚本实现彩色进度条
- shell脚本实现彩色进度条
- shell写的彩色进度条
- shell脚本--实现彩色进度条
- docker 使用centos 镜像 运行 javaweb ,并重新生成镜像
- include、include_once、require、require_once的区别
- 前端面试整理<特别多,耐心看基础面试题部分基本没有问题了!!!>
- Coin Change
- 19.组合模式
- Linux日常——shell彩色进度条
- First Position Unique Character
- 暑期项目开发实训 Day7
- Android面试题记录
- 你必须要掌握的测试利器--TestNG
- 20.迭代器模式
- 51Nod-1967-路径定向
- React总结3:ES6下React组件的写法示例代码
- 经典错误一