Shell笔记

1、给ping加上时间

#!/bin/bash
ping -c3 192.168.0.8 | grep 'ttl' | awk '{now=strftime("%Y-%m-%d %H:%M:%S "); print now $0}' 

2、日志处理

# mv machine.log machine.log.2011-10-19
cat machine.log* | grep FAILED > FAILED.log
awk -F, '{print $2}' FAILED.log | uniq > card.txt
while read card;do cat machine.log* | grep -a $card > $card.log;done < card.txt
 

你可能感兴趣的:(grep,bash,ping)