# sed problems - Bash Script

**URL:** <https://community.unix.com/t/sed-problems-bash-script/366149>\
**Category:** Shell Programming and Scripting\
**Created:** [April 17, 2017, 3:39am UTC](https://community.unix.com/t/sed-problems-bash-script/366149 "2017-04-17T03:39:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![spbr](https://community.unix.com/user_avatar/community.unix.com/spbr/32/9823_2.png) [@spbr](https://community.unix.com/u/spbr)\
**Post date:** [April 17, 2017, 3:39am UTC](https://community.unix.com/t/sed-problems-bash-script/366149/1 "2017-04-17T03:39:36Z")

</div>

Hi  
I keep getting the following error

```nohighlight
sed: -e expression #1, char 32: unterminated `s' command
sed: -e expression #1, char 35: unterminated `s' command
sed: -e expression #1, char 35: unterminated `s' command

```

whenever I use the following bash script

```nohighlight
#! /bin/bash
mailgmail="smtp\.gmail\.com:587"
mailyahoo="smtp\.mail\.yahoo\.com:587"
echo "Email:"
        read emailuse
echo "Password:"
        read emailpass
sed -i "6s/.*/root=$emailuse/" /etc/ssmtp/ssmtp.conf
sed -i "25s/.*/AuthUser=$emailuse/" /etc/ssmtp/ssmtp.conf
sed -i "26s/.*/AuthPass=$emailpass/" /etc/ssmtp/ssmtp.conf
if [["$emailuse" == *"gmail"*]]; then
        sed -i "10s/.*/mail=$mailgmail" /etc/ssmtp/ssmtp.conf
        sed -i "23s/.*/mailhub=$mailgmail" /etc/ssmtp/ssmtp.conf
        sed -i "28s/.*/mailhub=$mailgmail" /etc/ssmtp/ssmtp.conf
elif [["$emailuse" == *"yahoo"*]]; then
        sed -i "10s/.*/mail=$mailyahoo" /etc/ssmtp/ssmtp.conf
        sed -i "23s/.*/mailhub=$mailyahoo" /etc/ssmtp/ssmtp.conf
        sed -i "28s/.*/mailhub=$mailyahoo" /etc/ssmtp/ssmtp.conf
else
        echo "Use another email address with yahoo or gmail"

fi

```

Thank you

---

<div class="post-metadata">

**Author:** ![RudiC](https://community.unix.com/letter_avatar/rudic/32/6_22734026db12803ebb3e059622ac3534.png) [@RudiC](https://community.unix.com/u/RudiC)\
**Post date:** [April 17, 2017, 7:03am UTC](https://community.unix.com/t/sed-problems-bash-script/366149/2 "2017-04-17T07:03:44Z")

</div>

Reading the error messages carefully: try terminating each of those `sed``s` ubstitute commands with a slash...

---

<div class="post-metadata">

**Author:** ![MadeInGermany](https://community.unix.com/letter_avatar/madeingermany/32/6_22734026db12803ebb3e059622ac3534.png) [@MadeInGermany](https://community.unix.com/u/MadeInGermany)\
**Post date:** [April 17, 2017, 3:01pm UTC](https://community.unix.com/t/sed-problems-bash-script/366149/3 "2017-04-17T15:01:22Z")

</div>

The closing `/` are missing. For example

```nohighlight
    sed -i "
      10s/.*/mail=$mailgmail/
      23s/.*/mailhub=$mailgmail/
      28s/.*/mailhub=$mailgmail/
    " /etc/ssmtp/ssmtp.conf

```

Multi-statement per one sed is more efficient.
