# when: search stdout\_lines

**URL:** <https://forum.ansible.com/t/when-search-stdout-lines/26882>\
**Category:** Ansible Project\
**Created:** [March 1, 2018, 11:00pm UTC](https://forum.ansible.com/t/when-search-stdout-lines/26882 "2018-03-01T23:00:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_Harmon](https://avatars.discourse-cdn.com/v4/letter/j/edb3f5/32.png) [@John\_Harmon](https://forum.ansible.com/u/John_Harmon)\
**Post date:** [March 1, 2018, 11:00pm UTC](https://forum.ansible.com/t/when-search-stdout-lines/26882/1 "2018-03-01T23:00:33Z")

</div>

I can’t seem to find the proper syntax to search the stdout\_lines for a string. Consider the following.

`  
tasks:

- name: List home dirs  
shell: “ls /home”  
register: home  
changed\_when: false

- name: List scripts directory  
shell: “ls /home/gomer/Scripts/ | wc -l”  
changed\_when: false  
when: “gomer” in home.stdout\_lines

`

I have tried all sorts of combinations to search (regexp, etc), but whatever I try fails… can someone point me in the right direction?

---

<div class="post-metadata">

**Author:** ![John\_Harmon](https://avatars.discourse-cdn.com/v4/letter/j/edb3f5/32.png) [@John\_Harmon](https://forum.ansible.com/u/John_Harmon)\
**Post date:** [March 1, 2018, 11:03pm UTC](https://forum.ansible.com/t/when-search-stdout-lines/26882/2 "2018-03-01T23:03:07Z")

</div>

Figured it out:

` `when: ‘“gomer” in home.stdout\_lines’` `
