Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
161 views
in Technique[技术] by (71.8m points)

character in shell script

I get the below error while trying to execute a shell script,

$'
': command not found: line 2:

Please suggest a solution for the same.

Below are the intial lines used in the script,

#!/bin/sh

if [[ $# -lt 1 ]]; then
   echo "ERROR Environment argument missing <dev,test,qa,prod>"
   export RC=50
   exit $RC
fi
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Your problem is that the file has Windows line endings. This can be caused by editing a file in Windows and trying to run it on a non-Windows system.

You can fix this problem using dos2unix to convert the line endings:

dos2unix ConstruedTermsXMLGenerator.sh

The corresponding utility to convert in the other direction is unix2dos.

Some systems have fromdos and todos.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...