I am getting confused about Linux shells. It may be that I oversee something obvious as a Linux noob.
All I want is the following script to run:
#!/b
Here are a list of editors that support unix newline character.
Brackets has an extension for new-line/end-of-line support and it is built-in in Notepad++. Go to the 'Edit' tab. Find 'EOL Conversions' and select Unix (LF). That should get it done.
There are most probably carriage returns (CR, '\r'
) at the end of your lines in the shell script, so the variable is trying to be read into var\r
instead of var
. This is why your error message is meaningless. A similar error should look like this:
run.sh: 3: export: [... the variable name]: bad variable name
In your case bash throws an error because var\r
is illegal for a variable name due to the carriage return, so it prints
test.sh: 3: read: var\r: bad variable name
but the \r
jumps to the beginning of the line, overwriting the start of the error message.
Remove the carriage returns fom the ends of lines, possibly by using the dos2unix
utility.