Tuesday, June 2, 2009

$'\r': command not found

I was brushing up my shell scripting basics the other day. I had not run any shell scripts on the windows ( via cygwin) . So I thought I would start off with a simple hello world script :

#!/bin/bash
#
# hello.sh
#

echo "Hello World..!!!" # prints Hello World
exit 0

when I executed this script, I got

hello.sh: line 5: $'\r': command not found
Hello World..!!!

so, after a small search on the web I realized the obvious thing I had missed out.
I had to convert the file to UNIX format. I used the UNIX format shell utility dos2unix.
It worked perfectly well.

No comments: