# trouble with shell egrep escaping chars

**URL:** <https://forum.ansible.com/t/trouble-with-shell-egrep-escaping-chars/22199>\
**Category:** Ansible Project\
**Created:** [August 3, 2016, 8:39am UTC](https://forum.ansible.com/t/trouble-with-shell-egrep-escaping-chars/22199 "2016-08-03T08:39:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kai1](https://avatars.discourse-cdn.com/v4/letter/k/77aa72/32.png) [@Kai1](https://forum.ansible.com/u/Kai1)\
**Post date:** [August 3, 2016, 8:39am UTC](https://forum.ansible.com/t/trouble-with-shell-egrep-escaping-chars/22199/1 "2016-08-03T08:39:24Z")

</div>

Dear all,

I cannot get the following line to work:

shell: "{{java\_home}}/bin/java -version 2\>&1 | grep 'java version' |  
egrep '{{ '1\.[789]' | regex\_escape() }}'"

Obviously this line already went through quite some iterations, but I  
cannot get the YAML parser to even accept ist. It always throws a  
"Syntax Error while loading YAML" with a mark pointing to the "\" character.

Is there any chance gatting this to work (or testing for a allowed range  
of java version by any other means)?

Cheers, Kai

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [August 3, 2016, 10:18am UTC](https://forum.ansible.com/t/trouble-with-shell-egrep-escaping-chars/22199/2 "2016-08-03T10:18:04Z")

</div>

Escape the backslash and remove the regex\_escape()

shell: "{{java\_home}}/bin/java -version 2\>&1 | grep 'java version' | egrep '{{ '1\\.[789]' }}'"

---

<div class="post-metadata">

**Author:** ![Kai1](https://avatars.discourse-cdn.com/v4/letter/k/77aa72/32.png) [@Kai1](https://forum.ansible.com/u/Kai1)\
**Post date:** [August 9, 2016, 3:21pm UTC](https://forum.ansible.com/t/trouble-with-shell-egrep-escaping-chars/22199/3 "2016-08-09T15:21:00Z")

</div>

G'day!
