正規表現ってもっとすっきり書けるものだと思う…(´・ω・`)
lvとnkfが必要なのでapt-getで入れてくだしあ><
diff使えばreloadも書けるはず!で今diffを調べてる.
#!/bin/sh
menu(){
echo 1:ニュース速報
echo 2:ニュース速報+
echo q:quit
read no
case ${no} in
1)
url=http://dubai.2ch.net/news
;;
2)
url=http://mamono.2ch.net/newsplus
;;
q)
exit 0
;;
esac
geturl
}
geturl(){
wget ${url}/subject.txt
cat subject.txt | head -n 10 |grep -n "[0-9]" | nkf -w
read number
case ${number} in
q)
del
exit 0
;;
*)
dat=`grep -n -e "[0-9]*\.dat" subject.txt |head -n 10 |nkf -w |grep -e "^${number}:" |grep "[0-9]*\.dat" |sed -e "s/\.[^.]*//g" -e "s/${number}://g"`
wget ${url}/dat/${dat}.dat
rm subject.txt*
;;
esac
readdat
}
readdat(){
cat ${dat}.dat |nkf -w |sed "s/^[^0-9]*//g"|grep -n "[0-9]"| sed "s/ <br>\|ID:[0-9a-zA-Z/+-]*/\n/g"|sed "s/ <[^>]*>\|BE:.*\.gif//g" |sed "s/>/>/g" |lv
echo r:reload m:menu q:quit
read opera
operation ${opera}
}
reload(){
:;
}
del(){
rm subject.txt*
rm live.html*
rm *.dat*
}
operation(){
case ${opera} in
r)
reload
;;
m)
rm ${dat}.dat
menu
;;
q)
del
exit 0
;;
esac
}
while true;
do
menu
done
0 件のコメント:
コメントを投稿