我有一份 IP 列表,例如
35.195.23.184 134.209.172.147 207.90.244.14 179.43.191.98 77.90.22.16 222.95.163.138 95.214.53.91 45.230.66.15 199.45.155.111 5.8.11.202 185.191.126.248 154.83.15.156 71.6.232.28 35.204.124.189 141.98.11.178 64.62.197.44 64.62.197.36 64.62.197.33 185.242.226.99 46.19.69.70 114.33.100.55 95.214.55.79 114.35.57.211 162.191.196.61 87.120.126.85 2.196.195.65 118.163.142.112 80.82.77.202 182.44.10.178 114.38.214.165 175.107.1.178 122.116.134.171 109.205.213.198 178.215.238.69 122.116.158.160 93.174.93.12 147.45.112.17 59.126.25.244 59.126.254.199 40.83.134.151 125.228.162.168 220.134.106.248 45.115.89.120 4.255.98.186 87.120.114.229 45.84.89.3 46.174.191.28 95.214.53.211 141.98.11.175 125.228.214.129 36.139.63.123 180.149.126.8 122.116.183.60 185.82.219.179 165.154.206.35 106.75.146.146 106.75.169.16 59.126.115.226 59.182.82.59 47.91.91.123 34.77.49.75 45.148.10.206 45.156.130.18 87.236.176.150 167.94.145.96 199.45.154.130 205.210.31.30 147.185.132.30 64.62.156.83 35.203.210.49 100.0.161.38 1.34.209.79
(不必担心将它们发布在这里,它们都被蜜罐捕获,作为攻击性黑客源。
现在,在 bash-shell 中,我想重新格式化此列表 - 必须用逗号和空格 (, ) 替换它们之间的空格,以便在 hosts.deny 文件中轻松使用它们。我的问题是:正常的 bash 或 sed 替换总是失败,并出现错误“替换错误”。看来我需要以某种方式转义空格/逗号。
所以我的问题是:如何用逗号/空格组合替换此列表中的所有空格?
谢谢!