linux 中的shell相当于windows中的批处理吗?

来源:百度知道 编辑:UC知道 时间:2024/06/03 18:07:55

shell脚本大约等如批处理吧,当然shell 脚本
能力大得多,现在的shell,已可写出相当复杂
的应用, 而且你可随时改用不同的shell, ex:
zsh , ksh93t, bash, 例如我用bash 写的简单查询 A 股脚本,

#! /bin/sh
# astosk.sh by twfccc@gmail.com, public domain
# 查询A股脚本
# 用法: astock.sh 或者 astock.sh [A股代号] (例如: astock.sh 600900)

fetcher=wget
code=$1

if ! which "$fetcher" > /dev/null 2>&1
then
fetcher=curl
fi

if [ -z "$code" ]
then
printf "A股代号是? (例如 600900): "
read reply
code=$reply
fi
: ${code:?"没有A股代号"}

url="http://wap.163.com/wml/money/hq2.jsp?code=${code}"
GrepFilter="| grep -E -A15 '[0-9-]+[ \t]*[0-9]+:[0-9]+:[0-9]+'"
sedcmd="| sed '/.*:.*/!d;s/<[^>][^>]*>//g'"

case &q