# How to add a string in end of line Ansible

**URL:** <https://forum.ansible.com/t/how-to-add-a-string-in-end-of-line-ansible/3525>\
**Category:** Get Help\
**Created:** [January 29, 2024, 11:36pm UTC](https://forum.ansible.com/t/how-to-add-a-string-in-end-of-line-ansible/3525 "2024-01-29T23:36:22Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![jrglynn2](https://avatars.discourse-cdn.com/v4/letter/j/94ad74/32.png) [@jrglynn2](https://forum.ansible.com/u/jrglynn2)\
**Post date:** [January 29, 2024, 11:44pm UTC](https://forum.ansible.com/t/how-to-add-a-string-in-end-of-line-ansible/3525/2 "2024-01-29T23:44:13Z")

</div>

Is this what you are looking for? “Append to existing line” section ==\> [Bootstrap](https://www.freekb.net/Article?id=29)

```auto
Append to an existing line

Let's say foo.txt contains "Hello World". Here is how you would append "example" after Hello World.

- lineinfile:
    path: /tmp/foo.txt
    backrefs: true
    regexp: '^(old line)$'
    line: '\1 example'

```

---

_[View the full topic](https://forum.ansible.com/t/how-to-add-a-string-in-end-of-line-ansible/3525)._
