> ## Content Index
> Fetch the complete content index at: https://www.bagz.fr/llms.txt
> Use this file to discover other available public pages before exploring further.

# Write multiple lines to file in bash (script)
- URL: https://www.bagz.fr/write-multiple-lines-to-file-in-bash-script/
- Published: 2017-10-04T13:31:37.000Z
- Updated: 2017-10-04T13:31:37.000Z
- Author: bgazui
- Tags: Linux, #Migrated-1790668826633, #wp, #wp-post, #Import 2026-09-29 08:00

If you need to push multiple lines to one file through a bash script, you can simply use that syntax:

cat > /etc/ntp.conf << \_NTPconf\_  
 server 1.2.3.4  
 server 5.6.7.8  
\_NTPconf\_

**Tip:** Be aware that if you're using indentation, last line should not be indented (this would lead you to some errors).

If you want to add line instead of overwriting file (like we did in the previous example), just replace the "**\>**" with "**\>>**" after *cat* command.

cat >> /etc/ntp.conf << \_NTPconf\_  
 server 1.2.3.4  
 server 5.6.7.8  
\_NTPconf\_