Question: file name is nginx.conf

how can i replace nginx all listen ports using sed

```
    limit_req_zone $binary_remote_addr zone=one:30m rate=20r/s;
server {
    listen 80;listen 8080;listen 443 ssl;ssl_certificate server.crt;ssl_certificate_key server.key; ssl_protocols SSLv3 TLSv1.1 TLSv1.2;
    index index.php index.html index.htm;

```

i want replace this part:

```
listen 80;listen 8080;listen 443 ssl;

```

with new value, the new value is input by user

example - user can input this: 

```
listen 8181;listen 8083 ssl;

```

or 

```
listen 80;listen 8080;listen 8181;listen 9090;listen 443 ssl;

```

Note: user is free to use any values.

currently i use this command, but replaces only one value:

```
sed -i '0,/listen [0-9]*;/s//listen $NEW_PORT;/' nginx.conf

```

any help is appreciated 

thanks

Answer: 
try this work for me 

```
sed  -i 's/listen 80;listen 8080;listen 443 ssl;/listen 80;listen 8080;listen 8181;listen 9090;listen 443 ssl;/g' nginx.conf

```
i did it like this and works fine:

```
sed -i 's/listen.*ssl; *ssl_certificate/listen 80;listen 6666;listen 8888;listen 443 ssl;ssl_certificate/' nginx.conf

```

i replaced all strings between: `listen.*ssl; *ssl_certificate`

i added \* between `ssl; *ssl_certificate` to ignore spaces if present