使用 sed 从流中分离模式
Using sed to separate pattern from streams
我有一个文件,每一行都有日志条目,例如:
vert.x-worker-thread-5:606-5 [28281755664384/companyOfflineCaEnricherRSS] [oiq.contentdigestion.PipelineProcessorLink] - CertainClassifierPipelineProcessorInternal COMPLETE [75ms]: http://www.cadc.uscourts.gov/recordings/recordings.nsf/uscadcoralarguments.xml
vert.x-worker-thread-6:524-7 [28281755664384/companyWebAndEventWorkerMultiPass][oiq.contentdigestion.PipelineProcessorLink] - CertainClassifierPipelineProcessorInternal COMPLETE [54ms]: http://a1851.g.akamaitech.net/f/1851/2996/24h/cache.xerox.com/downloads/usa/en/c/CEO_Commitment.pdf
任何人都可以帮助我让 sed 命令将行处理成以下模式
companyOfflineCaEnricherRSS : CertainClassifierPipelineProcessorInternal 75
companyWebAndEventWorkerMultiPass : CertainClassifierPipelineProcessorInternal 54
使用此 sed 命令并获得预期的输出,
sed -r 's/[^\/]+.([^]]+).*- ([^ ]+)[^[]+.([^a-z]+).*/ : /' FileName
-r, --regexp-extended
use extended regular expressions in the script.
输出:
companyOfflineCaEnricherRSS : CertainClassifierPipelineProcessorInternal 75
companyWebAndEventWorkerMultiPass : CertainClassifierPipelineProcessorInternal 54
我有一个文件,每一行都有日志条目,例如:
vert.x-worker-thread-5:606-5 [28281755664384/companyOfflineCaEnricherRSS] [oiq.contentdigestion.PipelineProcessorLink] - CertainClassifierPipelineProcessorInternal COMPLETE [75ms]: http://www.cadc.uscourts.gov/recordings/recordings.nsf/uscadcoralarguments.xml
vert.x-worker-thread-6:524-7 [28281755664384/companyWebAndEventWorkerMultiPass][oiq.contentdigestion.PipelineProcessorLink] - CertainClassifierPipelineProcessorInternal COMPLETE [54ms]: http://a1851.g.akamaitech.net/f/1851/2996/24h/cache.xerox.com/downloads/usa/en/c/CEO_Commitment.pdf
任何人都可以帮助我让 sed 命令将行处理成以下模式
companyOfflineCaEnricherRSS : CertainClassifierPipelineProcessorInternal 75
companyWebAndEventWorkerMultiPass : CertainClassifierPipelineProcessorInternal 54
使用此 sed 命令并获得预期的输出,
sed -r 's/[^\/]+.([^]]+).*- ([^ ]+)[^[]+.([^a-z]+).*/ : /' FileName
-r, --regexp-extended
use extended regular expressions in the script.
输出:
companyOfflineCaEnricherRSS : CertainClassifierPipelineProcessorInternal 75 companyWebAndEventWorkerMultiPass : CertainClassifierPipelineProcessorInternal 54