title: What's wrong "syntax error near unexpected token `fi'"?
body: <p>I can't deal with the problem. I run the script (I'll attach it below), after the first question I get the error &quot;line 37 syntax error near unexpected token `fi'
  If fi is removed, nothing changes.
  Help me to understand...
  I tried many solutions, and dos2unix configuration, and double-checked all the indents</p>
  <pre><code>#!/bin/bash
  function pause (){
    read -p &quot;Press any key to continue ... &quot;
  }
  timedatectl set-timezone Atlantic/Reykjavik
  a=`date +&quot;%Y-%m-%d %H:%M:%S&quot;`
  echo -n -e &quot;Current Date/Time is    &quot; 
  date
  sleep 2
  read -p &quot;is it correct (Yes/No) ? &quot; CC
    if [ &quot;$CC&quot; == &quot;N&quot; -o &quot;$CC&quot; == &quot;n&quot; ];then 
      echo &quot;Exit testing ...&quot;
      exit
    fi 
  else
    read -p &quot;Do you want to change (Yes/No) ? &quot; CC
    if [ &quot;$CC&quot; == &quot;Y&quot; -o &quot;$CC&quot; == &quot;y&quot; ];then
      read -p &quot;Please input new date, format: YYYYMMDD  &quot; D
      NEWD=&quot;`echo $D | cut -b 1-4`&quot;-&quot;`echo $D | cut -b 5-6`&quot;-&quot;`echo $D | cut -b 7-8`&quot;    
      read -p &quot;Please input new time, format: HHMM   &quot; T
      NEWT=&quot;`echo $T | cut -b 1-2`&quot;:&quot;`echo $T | cut -b 3-4`&quot;:&quot;00&quot;    
      echo -n &quot;date -s '&quot; &gt; d.sh
      echo -n &quot;$NEWD $NEWT&quot; &gt;&gt; d.sh
      echo &quot;'&quot; &gt;&gt; d.sh
      chmod 777 d.sh
      ./d.sh
      echo
      sleep 1
      clock -w
      sleep 1
      a=`date +&quot;%Y-%m-%d %H:%M:%S&quot;`
      echo -n -e &quot;NEW Date/Time is&quot;&quot;\e[0;32m $a\e[0m&quot;&quot;, &quot;
      read -p &quot;Press ENTER to continue...&quot;
    fi
  </code></pre>
  <p>UPD: <a href="https://i.stack.imgur.com/oQ4j4.png" rel="nofollow noreferrer">enter image description here</a>
  Display after deletion &quot;else&quot;</p>
  <p><strong>UPD2</strong> <em><strong>This is second similar code that gives the same error. Plus, doesn't request the entry of information (&quot;Please input the First MAC address:)</strong></em></p>
  <p><a href="https://i.stack.imgur.com/TSxbF.png" rel="nofollow noreferrer">enter image description here</a></p>
  <pre><code>echo &quot;************************&quot;
  echo &quot;  Serial number setting &quot;
  echo &quot;************************&quot;
  
  SLEN=0
  while [ &quot;$SLEN&quot; != &quot;13&quot; ]
  do 
  read -p &quot;Please input Serial Number:&quot; sn
  SLEN=&quot;${#sn}&quot;
  done
  
  echo &quot;*************************&quot;
  echo &quot;   MAC-address setting   &quot;
  echo &quot;*************************&quot;
  
  PLEN=0
  until [ &quot;$PLEN&quot; == &quot;12&quot; ] &amp;&amp; [ &quot;$VID&quot; == &quot;0015B2&quot; ]
  do 
    read -p &quot;Please input the First MAC address: &quot; MACIN
    PLEN=&quot;${#MACIN}&quot;
    if [ $PLEN != 12 ];then 
      echo
      echo MAC address LENTH error !!
    fi
    MAC=`echo $MACIN | tr a-z A-Z`
    VID=`echo $MAC | cut -b 1-6`
    if [ &quot;$VID&quot; != &quot;0015B2&quot; ];then
      echo
      echo -n &quot;The first 6 digit MUST be&quot;
      echo -n -e &quot;\e[0;37;42m 0015B2 \e[0m&quot;, but you input 
      echo -e &quot;\e[0;37;41m $VID \e[0m&quot;&quot;!!&quot; 
    fi
  done
  </code></pre>