I use Cygwin on my laptop (DOS). I have a collection of scripts from my colleagues, and my own. I am not an IT person, not knowledgeable in Unix. I am following my colleagues' syntax and able to manage a few simple things.
The scripts worked well on my old laptop. I just changed laptop and installed Cygwin. When I run my scripts, they do not work. Here is one example of the error message I get:
line 1: $':\r': command not found
line 5: syntax error near unexpected token `$'\r''
line 5: `fi
Here are the top 5 lines of my script
:
iter=1
if [ -f iter.txt ]
then rm ./iter.txt
fi
Can someone please explain how I can get around this problem?
-b
flag when opening the file? It won't work without that. Read my answer carefully. – Wildcard Sep 08 '17 at 23:43vim
rather thanvi
, this answer would do better to mentionvim
's simplefileformat=unix
setting, or even the+ff
option towrite
. – JdeBP Sep 09 '17 at 07:12vim
can do this in two ways, one of which uses words. Or, better yet, to point to where this subordinate task has been answered over and over here in far more detail than any answer on this page, including https://unix.stackexchange.com/questions/88811/ just for starters. – JdeBP Sep 09 '17 at 07:23vi -b
,\r
are vim extensions anyway. not POSIX, not in nvi, elvis, Solaris vi... – Stéphane Chazelas Sep 19 '17 at 10:21