# Get indice in file if caracter present

**URL:** <https://forum.ansible.com/t/get-indice-in-file-if-caracter-present/29792>\
**Category:** Ansible Project\
**Created:** [February 27, 2019, 4:35pm UTC](https://forum.ansible.com/t/get-indice-in-file-if-caracter-present/29792 "2019-02-27T16:35:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ryad9200000](https://avatars.discourse-cdn.com/v4/letter/r/f04885/32.png) [@ryad9200000](https://forum.ansible.com/u/ryad9200000)\
**Post date:** [February 27, 2019, 4:35pm UTC](https://forum.ansible.com/t/get-indice-in-file-if-caracter-present/29792/1 "2019-02-27T16:35:39Z")

</div>

Hy all,

I have one file with this content:

1,user1,host1,appli1  
2,user2,host2,appli2

My problem is that i want an task who look if {{ ansible\_user}},{{inventory\_hostname}} == “user1,host1”

He must return ID of this line “1”

If {{ ansible\_user}},{{inventory\_hostname}} == “user2,host2” He must return “2”

How do it please ??

I test command lookup et lineinfile but it’s not works 😕

Thank you very much !! 😉

---

<div class="post-metadata">

**Author:** ![ryad9200000](https://avatars.discourse-cdn.com/v4/letter/r/f04885/32.png) [@ryad9200000](https://forum.ansible.com/u/ryad9200000)\
**Post date:** [February 28, 2019, 8:19am UTC](https://forum.ansible.com/t/get-indice-in-file-if-caracter-present/29792/2 "2019-02-28T08:19:07Z")

</div>

Uppp pleasee !!!

---

<div class="post-metadata">

**Author:** ![jean-yves](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@jean-yves](https://forum.ansible.com/u/jean-yves)\
**Post date:** [March 1, 2019, 11:02pm UTC](https://forum.ansible.com/t/get-indice-in-file-if-caracter-present/29792/3 "2019-03-01T23:02:22Z")

</div>

Please explain what you want to achieve, not the way you want to code

Regards,

JYL
