shell脚本动画小工具
程序员文章站
2022-06-26 09:22:35
看gif图: 脚本内容如下: !/usr/bin/env bash Author:博客园——骏马金龙 shell scripts:http://www.cnblogs.com/f ck need u/p/7048359.html Usage:$0 "COMMAND" you must enclosi ......
看gif图:
脚本内容如下:
#!/usr/bin/env bash ## ------------------------------------------------------------ ## author:博客园——骏马金龙 ## shell scripts:http://www.cnblogs.com/f-ck-need-u/p/7048359.html ## ------------------------------------------------------------ ## usage:$0 "command" ## you must enclosing the command by double-quotes ## example1: $0 "sleep 3;echo haha" ## example2: $0 "service mysql start" killmyself="pkill -13 -f `basename $0`" trap "$killmyself" sigint while true;do for i in '-' '\' '|' '/';do printf "\r%s" $i sleep 0.2 done done & printf "\r%s\n" "`bash -c \"$@\"`" $killmyself
必须将待运行的命令放进引号中包围,并作为脚本的参数。
## example1: $0 "sleep 3;echo haha" ## example2: $0 "service mysql start" ## example3: $0 "service mysql stop"