Regular Expressions 101

Community Patterns

timestamped ping parser

1

Regular Expression
PCRE (PHP <7.3)

/
(\w+ (\w+) (\d+) (\d+:\d+:\d+) (\d+)) (?:\d+ bytes )?From (.+)icmp_seq=\d+ (ttl=\d+ )?(.*)(time=(\d+.\d+) ms)?
/
gmi

Description

ping -i 20 host | perl -nle 'print scalar(localtime), " ", $_'

Submitted by jb - 8 years ago