I have the following shell script ‘geturl.sh’:
wget -O /dev/null http://google.com/$1
wget -O /dev/null http://google.com/$1
When I run it with ‘./geturl.sh news’, it tries to wget http://google.com/news on the first line, and http://google.com/news on the second.
Why does it count the newline character and how do I fix it?
Thanks
if you created the file using a Unix editor, it wouldn’t/shouldn’t have the carriage return [chr(13), 0x0D, or ^M)] character. Unix newlines are linefeeds [chr(10), 0x0A, or ^J)] only. carriage returns don’t have any special meaning to the shell and usually result in unwanted behavior.
you can fix it using sed: