# copy content module is not readable, how to remove all special character and make it proper text readable

**URL:** <https://forum.ansible.com/t/copy-content-module-is-not-readable-how-to-remove-all-special-character-and-make-it-proper-text-readable/34637>\
**Category:** Ansible Project\
**Created:** [February 17, 2021, 9:09pm UTC](https://forum.ansible.com/t/copy-content-module-is-not-readable-how-to-remove-all-special-character-and-make-it-proper-text-readable/34637 "2021-02-17T21:09:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sameer\_Nagwekar](https://avatars.discourse-cdn.com/v4/letter/s/8c91f0/32.png) [@Sameer\_Nagwekar](https://forum.ansible.com/u/Sameer_Nagwekar)\
**Post date:** [February 17, 2021, 9:09pm UTC](https://forum.ansible.com/t/copy-content-module-is-not-readable-how-to-remove-all-special-character-and-make-it-proper-text-readable/34637/1 "2021-02-17T21:09:39Z")

</div>

I am able to run this playbook it copies the file to destination folder but it has all the special characters and the text is not in readable format. Any help in formatting the output file?

tasks:

- name: collect the config facts  
icx\_facts:  
gather\_subset:

- config  
register: result

- debug:  
var: result

- name: copy the output  
copy:  
content: “{{ result }}”  
dest: “/home/sameer/Documents/icx.txt”  
delegate\_to: localhost

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [February 18, 2021, 12:28am UTC](https://forum.ansible.com/t/copy-content-module-is-not-readable-how-to-remove-all-special-character-and-make-it-proper-text-readable/34637/2 "2021-02-18T00:28:14Z")

</div>

> I am able to run this playbook it copies the file to destination folder but it has all the special characters and the text is not in readable format. Any help in formatting the output file?

“special characters” is a bit ambiguous.  
What do you mean by that? How special are they?  
Same goes for “text is not in readable format”. Is the format unreadable for you? Or anyone? Or?

If you provide the output then this will avoid any confusion.

---

<div class="post-metadata">

**Author:** ![Sameer\_Nagwekar](https://avatars.discourse-cdn.com/v4/letter/s/8c91f0/32.png) [@Sameer\_Nagwekar](https://forum.ansible.com/u/Sameer_Nagwekar)\
**Post date:** [February 18, 2021, 5:10pm UTC](https://forum.ansible.com/t/copy-content-module-is-not-readable-how-to-remove-all-special-character-and-make-it-proper-text-readable/34637/3 "2021-02-18T17:10:32Z")

</div>

Sorry for being little ambiguous.  
Here is the output of my file when I read it. It is all clubbed together with newline \n and no proper formatting.

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [February 18, 2021, 5:47pm UTC](https://forum.ansible.com/t/copy-content-module-is-not-readable-how-to-remove-all-special-character-and-make-it-proper-text-readable/34637/4 "2021-02-18T17:47:01Z")

</div>

This is because your data is json formatted, but your debug uses yaml  
to display.  
It could be as simple as adding the to\_nice\_yaml filter, i.e.:

&nbsp;&nbsp;&nbsp;- name: copy the output  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;copy:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;content: "{{ result | to\_nice\_yaml }}"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dest: "/home/sameer/Documents/icx.txt"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;delegate\_to: localhost

---

<div class="post-metadata">

**Author:** ![Sameer\_Nagwekar](https://avatars.discourse-cdn.com/v4/letter/s/8c91f0/32.png) [@Sameer\_Nagwekar](https://forum.ansible.com/u/Sameer_Nagwekar)\
**Post date:** [February 18, 2021, 6:05pm UTC](https://forum.ansible.com/t/copy-content-module-is-not-readable-how-to-remove-all-special-character-and-make-it-proper-text-readable/34637/5 "2021-02-18T18:05:24Z")

</div>

Thank you so much that worked like a charm. This was my first successful playbook 🙂
