Glam Prestige Journal

Bright entertainment trends with youth appeal.

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
clear

when I run it by this commands:

bash name.sh

or

. name.sh

I got that error

bash: $'clear\r: command not found

in my script I have that for every line.

2

1 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

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy