I am new to Bash Script. I run the following simple script in Ubuntu like this:
sudo bash -x Script.sh
Output:
+ $'\r'
: command not found
+ $'\r'
: command not found
+ $'\r'
: command not found
+ adminEmail=$'[email protected]\r'
+ $'\r'
: command not found
' echo 'database name:
database name:
+ read $'dbname\r'
The actual script:
#!/bin/bash
# Installation script for latest Wordpress website on Ubuntu
#
# Kave
# December 27, 2011
adminEmail="[email protected]"
echo "database name:"
read dbname
What are all these '\r'
error messages coming up? Even the comments seem not to be understood...
Simply do
dos2unix scriptname
and execute your script.
If you don't have the tool you can do the following to install it.
sudo apt-get install dos2unix
OR
Do the following command line hacks to convert the file.
tr -d '\015' < scriptname > scriptname.new
OR
sed -i 's/\x0D$//' scriptname
You downloaded the file via a Windows machine, and you have CRLF line endings (that's \r\n
in C and related languages).
Remove the DOS line endings. For example, edit the file in vim
and change the format with :set fileformat=unix
(plus Return) and then write the file back out. Alternative techniques could use the tr
command, or dos2unix
or dtou
, depending on what's available.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With