Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
155 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 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...