title: a bash script to change postgresql user password
body: <p>I can change the postgresql user password in this way (2 steps):</p>
  
  <pre><code>$ su - postgres -c 'psql -U postgres -d postgres'
  # Alter user postgres with password 'password';
  </code></pre>
  
  <p>Now I want to use a single line command (1 step) to change the password such as:</p>
  
  <pre><code>su - postgres -c 'psql -U postgres -d postgres -c "alter user postgres with password ''password'';"'
  </code></pre>
  
  <p>I heard using double single quote to escape one single quote so I added double quote <code>'</code>. However is shows error message:</p>
  
  <pre><code>ERROR:  syntax error at or near "password"
  LINE 1: alter user postgres with password password;
  </code></pre>
  
  <p>Could someone let me know how to use one line of command to do this? </p>