Before you use any Unix tools to process some file, make sure the file only use Unix line endings.
Note that many text files you downloaded most probably use Windows line endings.
|Type||Line ending||Escape sequence|
|Unix (including Linux distro, *BSD and macOS)||LF||\n|
|Classic Mac OS (i.e. Mac OS 9 or older)||CR||\r|
Unix tools, regardless from Busy/ToyBox, GNU or BSD, only support Unix line endings.
So, before you use any of them, make sure you convert the file to Unix line endings, especially before
dos2unix to convert from Windows to Unix line endings, e.g.
# STDIN to STDOUT cat input | dos2unix # STDIN to FILE cat input | dos2unix > output # Convert and replace current file dos2unix filename
If your distro includes BusyBox (e.g. Ubuntu), use