1

i have an error that says line 17: unexpected end of file. i know others have already asked this, i tried to do the solutions given to them but still i am having the error. i am using ubuntu server 16.04 LTS. i used nano editor to write my bash.sh file. and i also downloaded the dos2unix already.

did the command sudo dos2unix bash.sh, it says converting file bash.sh to unix format...

after i do this i try to run again using sudo ./bash.sh usertest and i still have an error

my code is very simple just to test an argument:

USER=$1 
DATE=`date +%d%m%y` 
if [ -z "$1" ];then 
   echo "Wrong format"
   exit 1
else
   if [ -d "\home\$USERNAME" ]; then
     echo "correct"
fi
dessert
  • 39,982
Paul
  • 31

1 Answers1

3

this is the code you posted (formatted):

  USER=$1 
  DATE=date +%d%m%y 
  if [ -z "$1" ];then 
    echo "Wrong format" 
    exit 1 
  else 
    if [ -d "\home\$USERNAME" ]; then 
        echo "correct" 
    fi

Hopefully, you can see when formatted this way, you are missing a "fi" at the bottom of the script.

TonyB
  • 226