If you have the vim package installed on your Cygwin install, you can use vim to fix this without find & replace. Start vim as follows: vim filename.sh
(often it is aliased to vi also). Then, type :set fileformat=unix
, then :wq
(write & quit) to save your changes. (The :
puts you in vim's edit mode.)
I recommend this over dos2unix since vim is probably more commonly installed.
However, it is probably a best practice to set your text editor to save files that you plan to use in a Unix/Linux environment to have a Unix text format. The answers given above for Notepad++ are a good example.
Additional note: If you are unsure what type a file is (DOS or Unix), you may use the file filename.sh
. This can especially help in debugging more obscure issues (such as encoding issues when importing SQL dumps that come from Windows).
For other options on how to modify text file formatting, see this IU knowledge base article
More background information on Bash scripts and line endings is found on this StackOverflow question.