- 论坛徽章:
- 0
|
回复 1楼 may1492 的帖子
#!/bin/bash
export PATH=$PATH:/usr/local/bin:/bin:/usr/bin:/usr/local/mysql/bin
db=joomla
table=JLB_NEWS
e="<div align=center><img src=http://172.16.12.200/spimages"
mysql $db -uroot -p111111 --execute="set names utf8;
select news_id from JLB_NEWS;">/tmp/id
heigh=`cat /tmp/id | wc -l`
for (( i=2;i<=$heigh;i++ ))
do
k=`sed -n "$i p" /tmp/id`
echo " begin.........................$i....................$k.................."
mysql $db -uroot -p111111 --execute="set names utf8;select content from
$table where news_id=$k;">/tmp/1
c=`sed -n '/jpg/=' /tmp/1`
if [ -z $c ] ;then
mysql $db -uroot -p111111 --execute="set names utf8;
insert into tmp_jlb_news values('$k','$f');"
echo "the id no has jpg"
else
echo "the id has jpg"
a=`cat /tmp/1 | awk -F'image.cltsh.com' '{print $2}'`
g=$e$a
mysql $db -uroot -p111111 --execute="set names utf8;
insert into tmp_jlb_news values('$k','$g');"
echo "the end"
fi
done
我前天写的,通过SHELL和mysql的结合功能非常强大,一个写JAVA的朋友都说:没想到SHELL这么强。
[ 本帖最后由 lvscluster 于 2007-6-15 02:44 编辑 ] |
|