title: Change directory to Window's user directory in WSL bash script
body: <p>I am trying to write a script to automate installing some things in WSL and then cloning a repo to the user's home folder in Windows (e.g. C:/Users/Frank/).</p>
  
  <p>To do this I need to get the Windows username (e.g. <code>Frank</code>) to know where to <code>cd</code> to. I found that I could execute Windows command line commands with <code>cmd.exe /c '&lt;command&gt;'</code> and that the command <code>echo %USERNAME%</code> outputs the Windows user's username.</p>
  
  <p>This is what I've tried so far:</p>
  
  <pre class="lang-sh prettyprint-override"><code>#!/bin/bash
  USER_NAME=`cmd.exe /c 'echo %USERNAME%'`
  cd /mnt/c/Users/$USER_NAME
  pwd
  </code></pre>
  
  <p>I get an error that I believe stems from the Windows carriage return characters <code>\r</code> which I guess are at the end of the output of <code>echo %USERNAME%</code>.</p>
  
  <p>The error:
  <code>ine 3: cd: $'/mnt/c/Users/Frank\r\r\r': No such file or directory</code></p>
  
  <p>How can I remove all of the <code>\r</code> characters at the end of the output?</p>