Daily Shell processing commands

Source: Internet
Author: User
Use of shell processing commands in daily work #! /Bin/bash # batch package LOG/data/serverlog/shopDIR 'ls-l | grepJun | awk & amp; #39; {if ($7 ~ /9/) print $0} & amp; #39; | awk & amp; #39; $8 & gt; & quot; 17:30 & quot; & amp; #3

Use of shell processing commands in daily work

 

#! /Bin/bash
# Batch package log files

LOG =/data/serverlog/shop
DIR = 'ls-l | grep Jun | awk' {if ($7 ~ /9/) print $0} '| awk' $8> "17:30" '| awk' $8 <"21:30" '| awk' {print $9 }''

For I in $ DIR
Do
Cd $ LOG
Tar czvf/home/benet/shop.tar.gz $ I
Done

Common commands for querying log files:

Sudo netstat-auntpl | grep 11710 \ query Port 11710 PID

Sudo lsof-p PID | grep log \ query the current 11710 Port log path
 
Sudo ls-l | grep 11710 | grep lolobby | awk '$7 = "23" {print $0}' | sort-k8 \ query log file No. 23 of 11710 lolobby and press time sorting

Sudo ls-l | grep 11710 | awk '{if ($7 ~ /21/) print $0} '| sort-k8 \ query log files No. 11710 in chronological order

Sudo ls-l | grep Jun | awk '{if ($7 ~ /9 /) print $0} '| awk' $8> "" '| awk' $8 <"" '| awk' {print $9} '\ query from AM on January 1, June 9 log File

Sudo ls-l | grep Jun | awk '{if ($7 ~ /9 /) print $0} '| awk' $8> "17:30" '| awk' $8 <"21:30" '| awk' {print $9} '| xargs tar czvf/home /benet/log.tar.gz

 

 

This article is from the "fallenleaves" blog

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.