Parsing text file in python
<p>So I am trying to python program that will extract the round trip time from a web server ping stored in a text file. So what I basically have is a text file with this:</p>

<pre><code>    PING e11699.b.akamaiedge.net (104.100.153.112) 56(84) bytes of data.
    64 bytes from a104-100-153-112.deploy.static.akamaitechnologies.com (104.100.153.112): icmp_seq=1 ttl=60 time=17.2ms
    64 bytes from a104-100-153-112.deploy.static.akamaitechnologies.com (104.100.153.112): icmp_seq=2 ttl=60 time=12.6ms
    64 bytes from a104-100-153-112.deploy.static.akamaitechnologies.com (104.100.153.112): icmp_seq=3 ttl=60 time=11.7ms
    ... (a bunch more ping responses here)
    --- e11699.b.akamaiedge.net ping statistics ---
    86400 packets transmitted, 86377 received, 0% packet loss, time 86532481ms
    rtt min/avg/max/mdev = 6.281/18.045/1854.971/28.152 ms, pipe 2
</code></pre>

<p>I am very new to python and need help being able to use regex commands to extract only the times between "time=" and "ms"and send it to another text file to look like:</p>

<pre><code>11.7
12.6
17.2
...
</code></pre>

<p>Any help would be greatly appreciated!</p>

<p>Since you asked for Python, here it is:</p>

<pre><code>$ ping -c 4 8.8.8.8 | python -c 'import sys;[ sys.stdout.write(l.split("=")[-1]+"\n") for l in sys.stdin if "time=" in l]'            
10.5 ms

9.22 ms

9.37 ms

9.71 ms
</code></pre>

<p>Note, this has stdout buffering, so you may want to add <code>sys.stdout.flush()</code> . Feel free to convert this from one liner to a script</p>

text-processing python