Hey Jord! Thanks for the comment, and it took me on a bit of a goose chase.

Your “need” here is a bit odd, and I wonder whether you edited that script on a mac and copied it over. Your command isn’t understanding that a new line means “the last command is done” and instead is requiring an “end-of-command” character, the semi-colon.

I did a bit of checking, because it’s been a while since I did line-ending-wrangling (more-or-less since I stopped having to use an operating system from Microsoft as my daily-driver).

This is what a Linux system expects to see from a native file.


user@vps:~$ echo "Hello World" > endings
user@vps:~$ echo "Goodbye" >> endings
user@vps:~$ file endings
endings: ASCII text

Cool, so let’s look at what makes that valid for Linux. \r and \n are two different line-endings, Carriage Return and Line Feed, respectively. So let’s run a set of commands and see how that ends up. printf, by the way, is a great way to send different control characters into a file, which is fun, and often doesn’t work with echo.


user@vps:~$ printf "Hello World\nGoodbye\n" > n-endings
user@vps:~$ file n-endings
n-endings: ASCII text
user@vps:~$ printf "Hello World\rGoodbye\r" > r-endings
user@vps:~$ file r-endings
r-endings: ASCII text, with CR line terminators
user@vps:~$ printf "Hello World\r\nGoodbye\r\n" > rn-endings
user@vps:~$ file rn-endings
rn-endings: ASCII text, with CRLF line terminators
user@vps:~$ printf "Hello World\n\rGoodbye\n\r" > nr-endings
user@vps:~$ file nr-endings
nr-endings: ASCII text, with CR, LF line terminators

So text\n is what your Linux based file system expects to see. Just out of interest, let me open up a couple of those files in the text editor nano.

In r-endings, I got this line in the footer:
[ Read 2 lines (Converted from Mac format) ]

In rn-endings, I got this line in the footer:
[ Read 2 lines (Converted from DOS format) ]

So, the quickest way I know to fix this, on a one-by-one basis, is to edit the file with nano nano myfile, then press Ctrl+o (the shortcut at the bottom shows ^O) to write out the file and this then shows you can press Alt-m (or, in Nano terms, “Meta-m” written as “M-M”) to change it from “Mac Format” to “Linux Format”, and then hit enter. Exit with Ctrl+x. And if it is using “DOS Format”, same principle, but use Alt-d (or “M-D”) to toggle the DOS format flag off when you go into write.

Of course, if it’s not that, then I’m confused on why that script wants end-of-command terminators between each instruction, when a New-Line character would do!