title: Running the following 2 bash commands in Ansible
body: <p>I'm trying to create a playbook that incorporates the following 2 commands and due to their special characters, i cant get it to work. Is there a list of special characters i need to account for in ansible using a bash command?</p>
  <pre><code>    - name: If file exists compare new users.txt
        shell: &gt;
          diff -q users.txt  &lt;(getent passwd | awk -F: '{ print $1 }') 1&gt;/dev/null; error=&quot;$?&quot;
          getent passwd | awk -F: '{ print $1 }' &gt; users.txt
  </code></pre>
  <p>The error is</p>
  <pre><code>fatal: [localhost]: FAILED! =&gt; {
      &quot;changed&quot;: true,
      &quot;cmd&quot;: &quot;diff -q users.txt  &lt;(getent passwd | awk -F: '{ print $1}') 1&gt;/dev/null; error=\&quot;$?\&quot;\n&quot;,
      &quot;delta&quot;: &quot;0:00:00.002893&quot;,
      &quot;end&quot;: &quot;2022-08-19 23:43:07.324939&quot;,
      &quot;invocation&quot;: {
          &quot;module_args&quot;: {
              &quot;_raw_params&quot;: &quot;diff -q users.txt  &lt;(getent passwd | awk -F: '{ print $1}') 1&gt;/dev/null; error=\&quot;$?\&quot;\n&quot;,
              &quot;_uses_shell&quot;: true,
              &quot;argv&quot;: null,
              &quot;chdir&quot;: null,
              &quot;creates&quot;: null,
              &quot;executable&quot;: null,
              &quot;removes&quot;: null,
              &quot;stdin&quot;: null,
              &quot;stdin_add_newline&quot;: true,
              &quot;strip_empty_ends&quot;: true,
              &quot;warn&quot;: true
          }
      },
      &quot;msg&quot;: &quot;non-zero return code&quot;,
      &quot;rc&quot;: 1,
      &quot;start&quot;: &quot;2022-08-19 23:43:07.322046&quot;,
      &quot;stderr&quot;: &quot;/bin/sh: -c: line 0: syntax error near unexpected token `('\n/bin/sh: -c: line 0: `diff -q users.txt  &lt;(getent passwd | awk -F: '{ print $1}') 1&gt;/dev/null; error=\&quot;$?\&quot;'&quot;,
      &quot;stderr_lines&quot;: [
          &quot;/bin/sh: -c: line 0: syntax error near unexpected token `('&quot;,
          &quot;/bin/sh: -c: line 0: `diff -q users.txt  &lt;(getent passwd | awk -F: '{ print $1}') 1&gt;/dev/null; error=\&quot;$?\&quot;'&quot;
      ],
      &quot;stdout&quot;: &quot;&quot;,
      &quot;stdout_lines&quot;: []
  }
  </code></pre>