linux shell难吗
来源:百度知道 编辑:UC知道 时间:2024/06/27 14:29:35
不太难,要是你花点时间学, shell 编程对於系统管理员或是一般使用者
都相当有用,除了自动化,还可写出一些有趣的小工具, 例如
我为自己写了个代替fortune 的小玩意,在 terminal 启动时执行这脚本,
它会连上 randomfunfacts.com, 随机地提供一些有趣的事实,和 vista
一个 gedget 一样,我在 .bash_profile 加入
# have some fun
if [ -x $(which funfacts) ]
then
funfacts | tee /etc/motd
else
fortune -s | tee /etc/motd
fi
而脚本放在 $HOME/bin
该脚本很简单,如是
#! /bin/bash
# get random fun facts from randomfunfacts.com, like `fortune'does.
# $prog: funfacts twfccc@gmail.com, twf_cc@yahoo.com.hk
# $required: lynx or links needed, gnu grep 2.5.X and bash 3.X or above
url="randomfunfacts.com" # the website
browser=lynx # default text browser
if which links &> /dev/null
then
browser=links # better choice if system provide
fi
if ! which lynx &> /dev/null && ! which links &> /dev/null