好玩有趣的shell小脚本

本文介绍如何使用Shell脚本配合sl及cowsay命令创建有趣的视觉效果。包括让屏幕显示跑动的火车及输出多种图案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1,编写shell脚本通过sl命令使屏幕跑一辆火车

脚本制作编写:

1,首先需要先安装sl软件包,yum -y install sl

2,编写脚本。

#!/bin/bash
n=0
while (($n<=1));
do
sl
sleep 3s
done

执行脚本,即可出现上图效果。

2,编写shell脚本通过cowsay命令输出各种小图案。

1,需要先安装 cowsay软件包,yum -y install cowsay

2,编写脚本。

#!/bin/bash
for i in hellokitty kiss kitty koala kosh mech-and-cow meow milk moose mutilated ren satanic sheep skeleton small sodomized stegosaurus stimpy supermilker surgery telebears;
do
cowsay -f $i "坑爹啊"
sleep 3s
done

执行脚本,即可出现上图效果。

3,编写shell脚本通过boxes命令输出各种小图案。

1,需要先安装 boxes软件包,yum -y install boxes

2,编写脚本。

#!/bin/bash
for i in santa dog cat boy girl diamonds sunset xes unicornthink twisted spring peek mouse
do
echo "天雷好怕怕,劈的掉渣渣" | boxes -d $i -a c
echo
sleep 1s
done

boxes命令还支持好多图案,使用boxes -l即可查看所有支持的图案。

4,pv命令输出电影字幕效果

1,需要先安装 pv软件包,yum -y install pv

2,直接执行下面的命令即可~

echo "Happiness is like a pebble dropped into a pool to set in motion an ever-widening circle of ripples. As Stevenson has said, being happy is a duty." |pv -qL 10

大家可以自己在终端输出打印试试看,也可以通过编写shell脚本输出长篇短文看看字幕效果^_^

最后再声明下,此脚本编写全当娱乐,对实际生产没啥用哦!!!!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值