syntax error: unexpected end of file

1、脚本只有10行,报第11行错误??

[root@centos79 test]# bash test.sh
test.sh: line 11: syntax error: unexpected end of file
[root@centos79 test]# cat -n test.sh
     1  #!/bin/bash
     2
     3  #step1 check ped file
     4  uniqn=$(sed 's/\r//g' outcome.ped | cut -d " " -f 7- | sed 's/ /\n/g' | sort -u | wc -l)
     5  if [ $uniqn -gt 5 ]
     6  then
     7  echo "error, exception nucleotide: "
     8  sed 's/^M//g' outcome.ped | cut -d " " -f 7- | sed 's/ /\n/g' | sort -u | grep -v [ATGC0];
     9  exit
    10  echo "stage1 ok"

2、 原来是少了一个fi

[root@centos79 test]# cat test.sh
#!/bin/bash

#step1 check ped file
uniqn=$(sed 's/\r//g' outcome.ped | cut -d " " -f 7- | sed 's/ /\n/g' | sort -u | wc -l)
if [ $uniqn -gt 5 ]
then
echo "error, exception nucleotide: "
sed 's/^M//g' outcome.ped | cut -d " " -f 7- | sed 's/ /\n/g' | sort -u | grep -v [ATGC0];
exit
fi
echo "stage1 ok"
[root@centos79 test]# bash test.sh
stage1 ok

原文地址:https://www.cnblogs.com/liujiaxin2018/p/15489002.html