I wrote script in bash but I have problem when I try run it by terminal. I tried on Ubuntu and Debian.
For example, this is bash script:
#!/bin/bash
clearwhen I run it by this commands:
bash name.sh
or
. name.sh
I got that error
bash: $'clear\r: command not foundin my script I have that for every line.
21 Answer
"\r" is how bash prints the Carriage Return character. ("^M,0x0B) that some other systems use as part of their End-of-Line marker ("^M^J", Carriage Return, followed by LineFeed). Linux uses only "^J" (LineFeed) at End-of-line.
One way of clearing out the "\r" characters is through dos2unix, in the package of the same name.
Another way is:
tr -d "\r" <name.sh >a.tmp
mv a.tmp name.sh