# escaping in a shell module

**URL:** <https://forum.ansible.com/t/escaping-in-a-shell-module/34730>\
**Category:** Ansible Project\
**Tags:** ubuntu\
**Created:** [March 6, 2021, 12:18pm UTC](https://forum.ansible.com/t/escaping-in-a-shell-module/34730 "2021-03-06T12:18:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![danish09](https://avatars.discourse-cdn.com/v4/letter/d/919ad9/32.png) [@danish09](https://forum.ansible.com/u/danish09)\
**Post date:** [March 6, 2021, 12:18pm UTC](https://forum.ansible.com/t/escaping-in-a-shell-module/34730/1 "2021-03-06T12:18:16Z")

</div>

Hi,

ansible 2.4.0  
remote environment: ubuntu 14.04  
host/controller: Ubuntu 16.04.7 LTS

I have a task to extract some usernames from the passwd file

_- name: extract usernames from password file_  
_shell: “awk -v LIMIT=$UGIDLIMIT -F: '($3\>=LIMIT) && ($3!=65534) && ($6=”/sftp")’ /etc/passwd \> /home/xxxxxxxx/migrate/passwd.mig"_

However, I am not sure why ansible is complaining when I run the above command.

When I run the awk command on the server CLI it runs fine. I have even tried escaping “/sftp” with a \ but then awk complains so not sure how to g about it.

Thanks

Danish

---

<div class="post-metadata">

**Author:** ![danish09](https://avatars.discourse-cdn.com/v4/letter/d/919ad9/32.png) [@danish09](https://forum.ansible.com/u/danish09)\
**Post date:** [March 7, 2021, 7:22am UTC](https://forum.ansible.com/t/escaping-in-a-shell-module/34730/2 "2021-03-07T07:22:12Z")

</div>

Thanks everyone, got this working.

_awk -v LIMIT=$UGIDLIMIT -F’:’ ‘($3\>=LIMIT) && ($3!=65534) && ($6==“/sftp”)’ /etc/passwd \> /home/ xxxxxxxx /migrate/passwd.mig_
