# template - line break of bash script is skipped

**URL:** <https://forum.ansible.com/t/template-line-break-of-bash-script-is-skipped/37589>\
**Category:** Ansible Project\
**Created:** [January 30, 2023, 10:45am UTC](https://forum.ansible.com/t/template-line-break-of-bash-script-is-skipped/37589 "2023-01-30T10:45:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dulhaver](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dulhaver/32/1061_2.png) [@dulhaver](https://forum.ansible.com/u/dulhaver)\
**Post date:** [January 30, 2023, 10:45am UTC](https://forum.ansible.com/t/template-line-break-of-bash-script-is-skipped/37589/1 "2023-01-30T10:45:57Z")

</div>

I am using the template module for a bash script

There is a problem with these lines

&nbsp;&nbsp;&nbsp;cd $PGARCH  
&nbsp;&nbsp;&nbsp;{% raw %}while mapfile -t -n 20 ARCHIVE\_LOGS && ((${#ARCHIVE\_LOGS[@]})){% endraw %}  
&nbsp;&nbsp;&nbsp;do

they should be like below

&nbsp;&nbsp;&nbsp;cd $PGARCH  
&nbsp;&nbsp;&nbsp;while mapfile -t -n 20 ARCHIVE\_LOGS && ((${#ARCHIVE\_LOGS[@]}))  
&nbsp;&nbsp;&nbsp;do

but factually the line break does not survive, hence the while loop, does not work

&nbsp;&nbsp;&nbsp;cd $PGARCH  
&nbsp;&nbsp;&nbsp;while mapfile -t -n 20 ARCHIVE\_LOGS && ((${#ARCHIVE\_LOGS[@]}))do

I tried the change the .j2 to

&nbsp;&nbsp;&nbsp;cd $PGARCH  
&nbsp;&nbsp;&nbsp;{% raw %}while mapfile -t -n 20 ARCHIVE\_LOGS && ((${#ARCHIVE\_LOGS[@]})){% endraw %}\n  
&nbsp;&nbsp;&nbsp;do

this prevent the line breack from disappearing but the '\n' remains in the target file on the remote

how would I approach this?

---

<div class="post-metadata">

**Author:** ![utoddl](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/utoddl/32/249_2.png) [@utoddl](https://forum.ansible.com/u/utoddl)\
**Post date:** [January 30, 2023, 11:14am UTC](https://forum.ansible.com/t/template-line-break-of-bash-script-is-skipped/37589/2 "2023-01-30T11:14:57Z")

</div>

This works:

```auto
 **cd $PGARCH**  **{% raw -%}** **while mapfile -t -n 20 ARCHIVE_LOGS && ((${#ARCHIVE_LOGS[@]}))**  **{% endraw %}**  **do**

```

Or, if you had other Jinja variables to expand in that line, you could rewrite

```auto
 **${#ARCHIVE_LOGS[@]}**

```

---

<div class="post-metadata">

**Author:** ![dulhaver](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dulhaver/32/1061_2.png) [@dulhaver](https://forum.ansible.com/u/dulhaver)\
**Post date:** [January 30, 2023, 1:42pm UTC](https://forum.ansible.com/t/template-line-break-of-bash-script-is-skipped/37589/3 "2023-01-30T13:42:12Z")

</div>

spot on, thanks.
