I was modifying my .bashrc and made a mistake when editing my PS1 prompt. I should have tested it in my command line before modifying my .bashrc, but at this point it is too late.

The bash prompt keeps spewing the same error over and over again:

-bash: bad substitution: no closing `}' in ...

and I am not able to edit my .bashrc or issue any command. I am also not physically co-located with this machine so can only SSH.

How can I modify take control of my shell again and modify my .bashrc again please?

  • 1
    Try if you can sftp.
    – user147505
    Commented Jan 21, 2018 at 6:16

1 Answer 1


Prepare a minimal and functional .bashrc file locally and transfer it to the remote system using scp, sftp, rsync or by any other available way.

For example:

$ mkdir testing && cd testing
$ touch empty-bashrc
$ ssh username@remotehost mv .bashrc broken-bashrc
$ scp empty-bashrc username@remotehost:.bashrc

Depending on the way you have set up your shell on the remote machine, it may be enough to move the broken .bashrc out of the way. Alternatively, you may have to replace it rather than move it out of the way to not make the SSH shell session break. Only you know the way you've configured it.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .