我需要 zgrep 特定时间段,例如:from 1/Oct/2014 to 31/Mar/2015.
我试图这样做:
find . -name \*.* | xargs zgrep -E '/Oct/2014 | /Nov/2014 | /Dec/2014 | /Jan/2015 | /Feb/2015 | /Mar/2015 | /Feb/2015'| /Mar/2015'
但没用。我等了很长时间,却一无所获。
我想这并不重要,但我的结构看起来像:
~/Desktop/logs
├── first_folder
| ├── 11.11 (folder)
│ | ├── access_log
│ | ├── access_log.1.gz
│ | :
│ | └── access_log.40.gz
| └── 11.12 (folder)
│ ├── access_log
│ ├── access_log.1.gz
│ :
│ └── access_log.16.gz
├── second_folder (folder)
| ├── 31.11 (folder)
│ | ├── access_log
│ | ├── access_log.1.gz
│ | :
│ | └── access_log.20.gz
| └── 31.15 (folder)
│ ├── access_log
│ ├── access_log.1.gz
│ :
: └── access_log.38.gz
└── last_folder
├── 91.11 (folder)
| ├── access_log
| ├── access_log.1.gz
| :
| └── access_log.25.gz
└── 91.15 (folder)
├── access_log
├── access_log.1.gz
:
└── access_log.30.gz
答案1
大概分组你的朋友在吗
zgrep -E '/(Oct|Nov|Dec)/2014|/(Jan|Feb|Mar)/2015'
所以就像
find . -type f -name 'access_log*' -exec zgrep -E '/(Oct|Nov|Dec)/2014|/(Jan|Feb|Mar)/2015' {} +