#!/bin/bash
ipaddr="10.0.1.1"
count=10

echo "Ping to: $ipaddr"
echo "Ping count: $count"
echo "Ping average[ms]:"

#Pingコマンドを実行し、結果をファイルに出力
ping -c $count $ipaddr > ping.txt

#time=??ms部分をsedで取り出し(|¥で改行)
sed -n "s/^.*time=¥(.*¥) ms/¥1/p" ping.txt |¥
#行数(NR)で割って、平均を求める
awk '{sum+=$1} END{print sum/NR}' > ping2.txt

これを実行すると、エラーになってしまいます。

/Users/hoge/Ping/ping.sh: line 14: unexpected EOF while looking for matching `''
/Users/hoge/Ping/ping.sh: line 15: syntax error: unexpected end of file

Pingの結果は下記のようなフォーマットで返ってきています。

$ ping -c 10 10.0.1.1
PING 10.0.1.1 (10.0.1.1): 56 data bytes
64 bytes from 10.0.1.1: icmp_seq=0 ttl=255 time=3.019 ms
64 bytes from 10.0.1.1: icmp_seq=1 ttl=255 time=1.976 ms
64 bytes from 10.0.1.1: icmp_seq=2 ttl=255 time=1.973 ms
64 bytes from 10.0.1.1: icmp_seq=3 ttl=255 time=2.005 ms
64 bytes from 10.0.1.1: icmp_seq=4 ttl=255 time=1.959 ms
64 bytes from 10.0.1.1: icmp_seq=5 ttl=255 time=1.415 ms
64 bytes from 10.0.1.1: icmp_seq=6 ttl=255 time=1.977 ms
64 bytes from 10.0.1.1: icmp_seq=7 ttl=255 time=1.976 ms
64 bytes from 10.0.1.1: icmp_seq=8 ttl=255 time=1.453 ms
64 bytes from 10.0.1.1: icmp_seq=9 ttl=255 time=2.000 ms