# whitespace in stdout

**URL:** <https://forum.ansible.com/t/whitespace-in-stdout/15367>\
**Category:** Ansible Project\
**Created:** [May 29, 2014, 6:12pm UTC](https://forum.ansible.com/t/whitespace-in-stdout/15367 "2014-05-29T18:12:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![smajor](https://avatars.discourse-cdn.com/v4/letter/s/a4c791/32.png) [@smajor](https://forum.ansible.com/u/smajor)\
**Post date:** [May 29, 2014, 6:12pm UTC](https://forum.ansible.com/t/whitespace-in-stdout/15367/1 "2014-05-29T18:12:57Z")

</div>

hello, I am having a hard time finding anything in google on how to remove whitespace from the stdout results.

Here is the play:

tasks:

- name: get droplet IPs from inventory  
shell: ansible -i hosts testing --list-hosts  
register: droplet\_inventory

- debug: msg=“{{ item|e - }}”

with\_items: “{{ droplet\_inventory.stdout\_lines}}”

output:

> > 
> 
> > ok: [localhost] =\> (item= 10.128.164.13) =\> {
> 
> > “item”: " 10.128.164.13",
> 
> > “msg”: " 10.128.164.13"
> 
> > }
> 
> > ok: [localhost] =\> (item= 10.128.163.87) =\> {
> 
> > “item”: " 10.128.163.87",
> 
> > “msg”: " 10.128.163.87"
> 
> > }
> 
> > ok: [localhost] =\> (item= 10.128.163.89) =\> {
> 
> > “item”: " 10.128.163.89",
> 
> > “msg”: " 10.128.163.89"
> 
> > }
> 
> > ok: [localhost] =\> (item= 10.128.163.90) =\> {
> 
> > “item”: " 10.128.163.90",
> 
> > “msg”: " 10.128.163.90"
> 
> > }

How can I get rid of the leading whitespace?

---

<div class="post-metadata">

**Author:** ![smajor](https://avatars.discourse-cdn.com/v4/letter/s/a4c791/32.png) [@smajor](https://forum.ansible.com/u/smajor)\
**Post date:** [May 29, 2014, 6:36pm UTC](https://forum.ansible.com/t/whitespace-in-stdout/15367/2 "2014-05-29T18:36:56Z")

</div>

For now I solved this with:

- debug: msg={{ item|replace(’ ‘,’') }}  
with\_items: “{{ droplet\_inventory.stdout\_lines}}”

if anyone knows a better method please share.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [May 31, 2014, 4:12pm UTC](https://forum.ansible.com/t/whitespace-in-stdout/15367/3 "2014-05-31T16:12:40Z")

</div>

Unclear why you need to remove whitespace from output, can you explain your use case?
