有哪些好玩儿的shell脚本

定时更换桌面,并把天气和日期水印到桌面背景上。
有哪些好玩儿的shell脚本

添加到crontab中,赏心悦目。可以关注我专栏,里面有详细的实现过程和代码。
乱弹Linux之从入门到放弃 - 专栏
这两天在折腾bash做个《落网》的音乐电台。还没做好,做好之后会第一时间更新到专栏里面,基本功能已经实现了,剩下一堆BUG没解决。
有哪些好玩儿的shell脚本
【有哪些好玩儿的shell脚本】

■网友
1. pipes.sh
有哪些好玩儿的shell脚本


源码 (提醒: 这个是 bash shell 脚本可是 Ubuntu 现在 sh 命令默认指向 dash shell。所以要用 bash pipes.sh 执行而不是 sh pipes.sh ):
#!/bin/bash# The author of the original script is unknown to me. The first entry I can# find was posted at 2010-03-21 09:50:09 on Arch Linux Forums (doesn\u0026#39;t mean the# poster is the author at all):## Post your handy self made command line utilities (Page 37) / Programming \u0026amp; Scripting / Arch Linux Forums## I, Yu-Jie Lin, made a few changes and additions:## -p, -t, -R, and -C## Screenshot: http://flic.kr/p/dRnLVj# Screencast: http://youtu.be/5XnGSFg_gTk## And push the commits to Gist:## https://gist.github.com/4689307## I, Devin Samarin, made a few changes and additions:## -r can be 0 to mean "no limit".# Reset cursor visibility after done.# Cleanup for those people who want to quit with ^C## Pushed the changes to https://gist.github.com/4725048# hole1: https://gist.githubusercontent.com/livibetter/4689307/raw/949e43fe2962c2c97c8b1d974ff93dd053d9bd37/pipes.sh# hole2: Fun On The Terminal Part 2p=1f=75 s=13 r=2000 t=0w=$(tput cols) h=$(tput lines)# ab -\u0026gt; idx = a*4 + b# 0: up, 1: right, 2: down, 3: left# 00 means going up , then going up -\u0026gt; ┃# 12 means going right, then going down -\u0026gt; ┓sets=( "┃┏ ┓┛━┓ ┗┃┛┗ ┏━" "│╭ ╮╯─╮ ╰│╯╰ ╭─" "│┌ ┐┘─┐ └│┘└ ┌─" "║╔ ╗╝═╗ ╚║╝╚ ╔═")v="${sets}"RNDSTART=0NOCOLOR=0OPTIND=1while getopts "p:t:f:s:r:RCh" arg; docase $arg in p) ((p=(OPTARG\u0026gt;0)?OPTARG:p));; t) ((OPTARG\u0026gt;=0 \u0026amp;\u0026amp; OPTARG\u0026lt;${#sets})) \u0026amp;\u0026amp; v="${sets}";; f) ((f=(OPTARG\u0026gt;19 \u0026amp;\u0026amp; OPTARG\u0026lt;101)?OPTARG:f));; s) ((s=(OPTARG\u0026gt;4 \u0026amp;\u0026amp; OPTARG\u0026lt;16 )?OPTARG:s));; r) ((r=(OPTARG\u0026gt;=0)?OPTARG:r));; R) RNDSTART=1;; C) NOCOLOR=1;; h) echo -e "Usage: $(basename $0) ..." echo -e "Animated pipes terminal screensaver.\" echo -e " -p \\tnumber of pipes (D=1)." echo -e " -t } - 1))]\\ttype of pipes (D=0)." echo -e " -f \\tframerate (D=75)." echo -e " -s \\tprobability of a straight fitting (D=13)." echo -e " -r LIMIT\\treset after x characters, 0 if no limit (D=2000)." echo -e " -R \\t\\trandom starting point." echo -e " -C \\t\\tno color." echo -e " -h\\t\\thelp (this screen).\" exit 0;; esacdonecleanup() { tput rmcup tput cnorm exit 0}trap cleanup SIGHUP SIGINT SIGTERMfor (( i=1; i\u0026lt;=p; i++ )); do c=$((i%8)) n=0 l=0 ((x=RNDSTART==1?RANDOM*w/32768:w/2)) ((y=RNDSTART==1?RANDOM*h/32768:h/2))donetput smcuptput resettput civiswhile ! read -t0.0$((1000/f)) -n1; do for (( i=1; i\u0026lt;=p; i++ )); do # New position: ((${l}%2)) \u0026amp;\u0026amp; ((x+=-${l}+2,1)) || ((y+=${l}-1)) # Loop on edges (change color on loop): ((${x}\u0026gt;w||${x}\u0026lt;0||${y}\u0026gt;h||${y}\u0026lt;0)) \u0026amp;\u0026amp; ((c=RANDOM%8)) ((x=(x+w)%w)) ((y=(y+h)%h)) # New random direction: ((n=RANDOM%s-1)) ((n=(${n}\u0026gt;1||${n}==0)?${l}:${l}+${n})) ((n=(${n}\u0026lt;0)?3:${n}%4)) # Print: tput cup ${y} ${x} ] \u0026amp;\u0026amp; echo -ne "\\033}m" echo -n "${v:l*4+n:1}" l=${n} done ((r\u0026gt;0 \u0026amp;\u0026amp; t*p\u0026gt;=r)) \u0026amp;\u0026amp; tput reset \u0026amp;\u0026amp; tput civis \u0026amp;\u0026amp; t=0 || ((t++))donecleanup


推荐阅读