zoukankan      html  css  js  c++  java
  • Linux常用操作命令(二)

    ab命令压测:
    ab -n 1 -c 1 -p post.txt -T 'application/x-www-form-urlencoded' -H 'User-U:2Lh72GM2UumEAnZzMgGbwg==;User-D:2Lh72GM2UumEAnZzMgGbwg==' 'http://106.38.231.147/partake/incr'
    linux(debain内核)vim编辑post.txt下默认会有换行符$的存在,而且替换不掉,
    1>用idea或者UE来编辑
    2>进入vim设置 set binary(二进制,例如图片这样后面不能随意加换行符) set noendofline
     
     

    curl查看url的rt:

    curl -o /dev/null -s -w %{time_namelookup}::%{time_connect}::%{time_starttransfer}::%{time_total}::%{speed_download}"
    " "http://www.taobao.com"  
    0.014::0.015::0.018::0.019::1516256.00  
    • -o:把curl 返回的html、js 写到垃圾回收站[ /dev/null] 
    • -s:去掉所有状态
    •  -w:按照后面的格式写出rt
    • time_namelookup:DNS 解析域名[www.taobao.com]的时间 
    • time_connect:client和server端建立TCP 连接的时间
    • time_starttransfer:从client发出请求到web的server 响应第一个字节的时间;包括前面的2个时间  
    • time_total:client发出请求到web的server发送会所有的相应数据的时间
    • speed_download:下周速度  单位 byte/s
    linux截取某段时间的日志信息:
    1>
    cat admin-live.log | awk -F ',' '$1 >="2017-02-27 16:26:44" && $1 <="2017-02-27 16:42:01" ' 
     
    2>
    start_time='2017-02-27 16:26:44' && end_time='2017-02-27 16:42:01' && 
    idx_1=`cat -n admin-live.log|grep "${start_time}"|awk '{print $1}'` && idx_2=`cat -n admin-live.log|grep "${end_time}"|awk '{print $1}'` &&
    sed -n "${idx_1},${idx_2}p" admin-live.log 
     
     
    3>写成一个shell脚本(提供思路)
    grep -l "xxxx" 日志文件>tmpfile
    start_time="log里的开始时间"
    end_time="log里结束时间"
    idx_1=`cat -n  tmp|grep "${start_time}"|awk '{print $1}'`
    idx_2=`cat -n  tmp|grep "${end_time}"|awk '{print $1}'`
    sed -n "${idx_1},${idx_2}p"  tmpfile > result
    more result
    

    awk命令积累:

    1>awk某列数据大于100的相加

    awk -F '分隔符' '{if($列号>100){s+=$列号}}END{print s}' 文件名

     更多资料细节参考:http://www.runoob.com/linux/linux-comm-awk.html

     

      

  • 相关阅读:
    xml文档格式学习笔记
    Visual Studio学习记录
    Java学习笔记
    C#项目学习记录
    Linux命令行与shell脚本编程大全 学习笔记
    NodeJS (npm) 学习笔记
    Angular学习笔记
    TypeScript学习笔记
    java 项目相关 学习记录
    docker学习记录
  • 原文地址:https://www.cnblogs.com/cangqiongbingchen/p/6434357.html
Copyright © 2011-2022 走看看