# shell module and escaping special characters

**URL:** <https://forum.ansible.com/t/shell-module-and-escaping-special-characters/17669>\
**Category:** Ansible Project\
**Created:** [March 4, 2015, 10:17pm UTC](https://forum.ansible.com/t/shell-module-and-escaping-special-characters/17669 "2015-03-04T22:17:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jim\_McMahon](https://avatars.discourse-cdn.com/v4/letter/j/e8c25b/32.png) [@Jim\_McMahon](https://forum.ansible.com/u/Jim_McMahon)\
**Post date:** [March 4, 2015, 10:17pm UTC](https://forum.ansible.com/t/shell-module-and-escaping-special-characters/17669/1 "2015-03-04T22:17:34Z")

</div>

The shell module seems to escape special characters like \ and ". Is there a way so that the shell module doesn’t escape these characters? Are there any tips on how handle situations where you want double quotes?

---

<div class="post-metadata">

**Author:** ![jdelaporte](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jdelaporte/32/366_2.png) [@jdelaporte](https://forum.ansible.com/u/jdelaporte)\
**Post date:** [March 5, 2015, 1:27am UTC](https://forum.ansible.com/t/shell-module-and-escaping-special-characters/17669/2 "2015-03-05T01:27:23Z")

</div>

I use shell a fair amount and have occasionally run into some similar issues. I sometimes wrap the entire shell command in single or double quotes, if it contains a special character. An example:

- name: determine firefox version  
shell: “firefox -v | cut -d ’ ’ -f3”  
register: ffversion

I also used double quotes with sed commands in the past, but lineinfile works just as well. However, I sometimes have to play with the quote placement for a while to make lineinfile work.

Joanna

---

<div class="post-metadata">

**Author:** ![Jim\_McMahon](https://avatars.discourse-cdn.com/v4/letter/j/e8c25b/32.png) [@Jim\_McMahon](https://forum.ansible.com/u/Jim_McMahon)\
**Post date:** [March 5, 2015, 4:10am UTC](https://forum.ansible.com/t/shell-module-and-escaping-special-characters/17669/3 "2015-03-05T04:10:58Z")

</div>

Thanks Joanna.

I think I’ve solved my particular issue by making heavy use of templates where I can put the double quotes and backslashes where I need them, then use the dest file as input to a command (e.g., mysql \< my template.sql)

Jim
