- 论坛徽章:
- 0
|
- #!/bin/sh
- TIME=`date +%H%M%S`
- number()
- {
- i=$1
- while((i--))
- do
- printf "sz"
- printf "%06d" $i
- printf ","
- done
- }
- get()
- {
- >/tmp/aaa
- stock_code=1256
- while ((stock_code-=157))
- do
- stock_number=`number $stock_code|awk -F, '{i=1;while(i<157){printf "%s%s",$i,FS;i++};printf "%s\n",$i}'|sed 's/,,//g'`
- stock_head="http://hq.sinajs.cn/list="
- stock_url=`echo $stock_head$stock_number`
- curl $stock_url >>/tmp/aaa
- done
- cat /tmp/aaa|grep -v \"\"|sort|awk -Fsz '{print $2}'|sed 's/="/,/g' >/tmp/bbb
- }
- [ $TIME -gt 93000 -a $TIME -lt 110000 -o $TIME -gt 133000 -a $TIME -lt 150000 ] && get || echo "not update time now!"
- echo "TOP 10"
- echo "______________________________________________________________________________"
- cat /tmp/aaa|grep -v \"\"|sort|awk -Fsz '{print $2}'|sed 's/="/,/g'|awk -F, '{ print ($5 - $4) / $4 * 100" "$1" "$2}'|grep -v -|sort -r|head -10
- echo "TOP -10"
- echo "______________________________________________________________________________"
- cat /tmp/aaa|grep -v \"\"|sort|awk -Fsz '{print $2}'|sed 's/="/,/g'|awk -F, '{ print ($5 - $4) / $4 * 100" "$1" "$2}'|grep -|sort -r|head -10
- #cat /tmp/aaa|grep -v \"\"|sort|awk -Fsz '{print $2}'|sed 's/="/,/g'|awk -F, '{ print ($6 - $7) / $4 * 100" "$1" "$2}'|sort -r
- echo "______________________________________________________________________________"
- echo "Enter stock code like 000XXX,such as 000001"
- echo "Enter Q/q to quit"
- echo "______________________________________________________________________________"
- while true
- do
- echo -n "Please print stock code:"
- read -r code
- if [ -z $code ];then
- echo "You enter nothing for search!"
- elif [[ $code =~ ^[0-9]{6}$ ]];then
- chkcode=`cat /tmp/aaa|grep $code|awk -F, '{if(NF>5){print $5}else{ print "niu"}}'`
- if [ x"$chkcode" = x ];then
- echo "No such stock as your entering!"
- elif [ $chkcode == "niu" ];then
- echo "No such stock as your entering!"
- else
- cat /tmp/aaa|grep $code|grep -v \"\"|sort|awk -Fsz '{print $2}'|sed 's/="/,/g'|awk -F, '{ print ($5 - $4) / $4 * 100" "$1" "$2}'
- fi
- elif [ $code == Q ];then
- exit 0
- elif [ $code == q ];then
- exit 0
- else
- echo "Enter error!"
- fi
- done
复制代码 回复 1# cao_doctor
|
|