zoukankan      html  css  js  c++  java
  • awk打印倒数第2列

    cat 1-iplist.txt | awk '{ print $(NF-2) }'|wc
    

      

    实际示例: 打印nginx日志中 变量request_time超过3秒的日志信息 

    [root@dataline-prod scripts]# cat /var/log/nginx/access.log |awk '{print $0}'|awk -F '"' ' $(NF-1)>3 '
    125.121.14.250 - - [29/Oct/2018:09:39:54 +0800] "GET /api/item/hot-item-list?firstCategoryName=%E4%B8%8A%E8%A1%A3&secondCategoryName=%E6%A3%89%E7%BE%BD%E7%BB%92%E6%9C%8D&shopFilterStatus=1&dateRangeStatus=2&minPrice=100200&maxPrice=&shopStyle=&shopType=&itemColor=&shopLikeName=&business=%E5%A5%B3%E8%A3%85&rankStatus=&startDate=2018-10-21&endDate=2018-10-28&pageNo=1&pageSize=20 HTTP/1.1" 200 185 "https://www.zhiyitech.cn/page/dataline/recommend" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0 Safari/605.1.15" "-" "3.041"
    125.121.14.250 - - [29/Oct/2018:09:39:56 +0800] "GET /api/item/hot-item-list?firstCategoryName=%E4%B8%8A%E8%A1%A3&secondCategoryName=%E6%A3%89%E7%BE%BD%E7%BB%92%E6%9C%8D&shopFilterStatus=1&dateRangeStatus=2&minPrice=10020&maxPrice=&shopStyle=&shopType=&itemColor=&shopLikeName=&business=%E5%A5%B3%E8%A3%85&rankStatus=&startDate=2018-10-21&endDate=2018-10-28&pageNo=1&pageSize=20 HTTP/1.1" 200 185 "https://www.zhiyitech.cn/page/dataline/recommend" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0 Safari/605.1.15" "-" "4.957"
    125.121.14.250 - - [29/Oct/2018:09:40:22 +0800] "GET /api/item/hot-item-list?firstCategoryName=%E4%B8%8A%E8%A1%A3&secondCategoryName=%E5%A4%B9%E5%85%8B&shopFilterStatus=1&dateRangeStatus=2&minPrice=10050&maxPrice=&shopStyle=&shopType=&itemColor=&shopLikeName=&business=%E5%A5%B3%E8%A3%85&rankStatus=&startDate=2018-10-21&endDate=2018-10-28&pageNo=1&pageSize=20 HTTP/1.1" 200 185 "https://www.zhiyitech.cn/page/dataline/recommend" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0 Safari/605.1.15" "-" "3.085"
    
    
    reqeust_time 信息位于日志的最后一列
    

      

  • 相关阅读:
    Nginx负载均衡
    MySQL主从复制
    笔记
    tomcat工作原理
    Nginx工作原理
    Loj#6183. 看无可看
    [BZOJ 2759] 一个动态树好题
    5255 -- 【FJOI2016】神秘数
    [NOI2015]寿司晚宴
    [CQOI2017]老C的键盘
  • 原文地址:https://www.cnblogs.com/weifeng1463/p/9869344.html
Copyright © 2011-2022 走看看