首页 > 系统服务 > 详细

linux之shell脚本学习篇一

时间:2016-01-11 15:12:57      阅读:220      评论:0      收藏:0      [点我收藏+]
此文包含脚本服务请求,字符串截取,文件读写内容,打印内容换行。
#!/bin/bash
retMsg="";
while read LINE
do
        echo "this is text: $LINE";
        retMsg=`/usr/bin/curl -o test3.log -w %{http_code}"\\n"  $LINE`; #http请求, 响应内容写文件以及响应状态码
        echo "Retutn value is text: $http_code";
        if [ "$retMsg" == "200" ]
        then
                echo "请求服务成功";
        #else
        #        echo "请求服务失败";
                while read MOBILE
                do
                   echo "The rtn mobile is $MOBILE";
                   a="$MOBILE";
                   info=`echo  "$a"|awk  -F ‘,‘ ‘{print $1}‘`; #按,截取字符串
                   url=`echo  "$a"|awk -F ‘,‘ ‘{print $2}‘`; #按,截取字符串
                   echo -e "截取后的字符串:\n$info\n$url"; #字符串换行
                done < mobile.txt
        fi
done < serverList.txt #读文件

linux之shell脚本学习篇一

原文:http://www.cnblogs.com/FCWORLD/p/5121307.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!