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