# How to capture/filter stdout\_lines

**URL:** <https://forum.ansible.com/t/how-to-capture-filter-stdout-lines/30087>\
**Category:** Ansible Project\
**Tags:** ansible-project\
**Created:** [April 10, 2019, 5:46am UTC](https://forum.ansible.com/t/how-to-capture-filter-stdout-lines/30087 "2019-04-10T05:46:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sebastian\_Meyer](https://avatars.discourse-cdn.com/v4/letter/s/779978/32.png) [@Sebastian\_Meyer](https://forum.ansible.com/u/Sebastian_Meyer)\
**Post date:** [April 10, 2019, 5:46am UTC](https://forum.ansible.com/t/how-to-capture-filter-stdout-lines/30087/1 "2019-04-10T05:46:56Z")

</div>

> Stdout\_lines that I get contains strings , json in different lines.
> 
> I want to capture the last line and copy those contents to a a new Json file.
> 
> How do I capture the last line from the registered variable.
> 
> I tried this and it didn't work.
> 
> "{{ Regvar.stdout\_lines | last }}"

Try

{{ regvar.stdout\_lines[-1] }}
