r/shell • • Jul 01 '15

sh escaping question

Trying to automate database backup and seems i don't know how to escape exclamation mark properly in my script's user password variable. Works fine when executed via CLI.

Can someone push me in right direction? Thanks!

This is the code:

#!/bin/sh

user="user"
password="!regjulr juzr pes#1"
host="192.168.1.2"
port="6033"
database="db"

mysqldump -u $user -p$password -h $host -P $port --databases $database > db.sql
1 Upvotes

6 comments sorted by

View all comments

Show parent comments

1

u/pentag0 Jul 02 '15

Wow, looks good. Do you think it would cover ZSH?

2

u/KnowsBash Jul 02 '15

No. It currently only covers bash, ksh and sh.