linux之shell脚本学习篇一
2016-01-11 15:05
351 查看
此文包含脚本服务请求,字符串截取,文件读写内容,打印内容换行。
#!/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 #读文件
#!/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 #读文件
相关文章推荐
- shell的常用特殊符号
- Android_shell编程
- Shell Python 日期和时间戳的互相转换
- Shell标准输出、标准错误 >/dev/null 2>&1
- linux shell
- Linux shell 学习
- hbase shell入门
- shell脚本报错---ge: unary operator expected
- shell 中的特殊符号的含义
- shell中$的用法
- shell修改文件名
- shell技巧
- Xshell连接CentOS问题分析
- YARN DistributedShell源码分析与修改
- Shell学习笔记
- awk
- 那些年我们一起做过的shell面试题(三)
- shell---登录失败的IP添加到/etc/hosts.deny
- shell 环境详解
- cygwin安装教程以及使用notepad++编写shell脚本,并通过cygwin运行