My script is supposed to take input from a pipe and replace newline characters with commas, using the bash's string substitution: #! /bin/bashread -d -r input echo $input $input=${input//\n/,}echo $inputHowever, instead of replacing the newline character, bash tries to execute the first matching pattern: echo -e this\nis\na\ntest\n | test.sh will give the following output: test.sh: line 5: this: command not found and the variable $input is not changed. Double or single quotes did not help either. I'm using bash version 4.3.11 on Linux Mint. 
Why does bash try to execute strings in a string substitution?
bash;shell;shell script;string
Remove the $ from the assignment line inside the loop. You're trying to use the value as the name of the variable you're assigning to, which is causing Very Strange Behavior.