# Can lineinfile append a string at a end of a particular line

**URL:** <https://forum.ansible.com/t/can-lineinfile-append-a-string-at-a-end-of-a-particular-line/18307>\
**Category:** Ansible Project\
**Created:** [May 26, 2015, 11:14am UTC](https://forum.ansible.com/t/can-lineinfile-append-a-string-at-a-end-of-a-particular-line/18307 "2015-05-26T11:14:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![txavier](https://avatars.discourse-cdn.com/v4/letter/t/858c86/32.png) [@txavier](https://forum.ansible.com/u/txavier)\
**Post date:** [May 26, 2015, 11:14am UTC](https://forum.ansible.com/t/can-lineinfile-append-a-string-at-a-end-of-a-particular-line/18307/1 "2015-05-26T11:14:39Z")

</div>

Hi All,

I’m new to ansible can you please help to append a string at the end of a particular line in server.xml file

**String=** packetSize=“65536”

**line=**

**I need something like this**

Many Thanks  
Thomas Xavier

---

<div class="post-metadata">

**Author:** ![Toshio\_Kuratomi](https://avatars.discourse-cdn.com/v4/letter/t/41988e/32.png) [@Toshio\_Kuratomi](https://forum.ansible.com/u/Toshio_Kuratomi)\
**Post date:** [May 26, 2015, 4:45pm UTC](https://forum.ansible.com/t/can-lineinfile-append-a-string-at-a-end-of-a-particular-line/18307/2 "2015-05-26T16:45:24Z")

</div>

lineinfile cannot do that but I believe the replace module can:

[http://docs.ansible.com/replace\_module.html](http://docs.ansible.com/replace_module.html)

Maybe something like this:

- replace: dest=/file/name regexp='(\s+\<Connector .\*)(/\>)$'  
replace='\1 packetSize="65536" \2'

-Toshio
