意外标记 `fi` 附近的语法错误 - Linux
Syntax error near unexpected token `fi` - Linux
我在 Windows 中使用 WSL (Ubuntu)。我在下面的脚本中使用了 bash script.sh
:
#! /bin/sh
#################LOAD FILES###################
lead_SNPs=`grep "lead_SNPs" ../prep/files.txt | cut -f2`
bfile=`grep -w "bfile" ../prep/files.txt | cut -f2`
bfile_list=`grep -w "bfile_list" ../prep/files.txt | cut -f2`
r2=`grep "r2" ../prep/parameters.txt | cut -f2`
###############LD###########################
if [ ${bfile} = "NA" ]; then
cat ${bfile_list} | while read line; do
file=${line}
file_n=`echo $file |awk -F '/' '{print $NF}'`
echo 'Calculating LD'
plink --bfile ${file} --r2 --ld-window-kb 1000 --ld-window 999999 --ld-window-r2 ${r2} --ld-snp-list ${lead_SNPs} --out C:/Users/naghm/Desktop/FDSP-github/ld/${file_n}
done
else
file=${bfile}
file_n=`echo $file |awk -F '/' '{print $NF}'`
echo ${file_n}
plink --bfile ${file} --r2 --ld-window-kb 1000 --ld-window 999999 --ld-window-r2 ${r2} --ld-snp-list ${lead_SNPs} --out C:/Users/naghm/Desktop/FDSP-github/ld/${file_n}
fi
但是我收到这个错误
Syntax error near unexpected token `fi`
你能更正我的代码吗?我不明白我哪里弄错了。
尝试改变:
if [ ${bfile} = "NA" ]; then
到
if [ "${bfile}" = "NA" ]; then
我怀疑 ${bfile} 是空的,扩展为:
if [ = "NA" ]; then
在您的原始行中。
您脚本的第一行看起来不正确。
应该是
#!/bin/sh
或者如果使用 bash shell:
#!/bin/bash
我在 Windows 中使用 WSL (Ubuntu)。我在下面的脚本中使用了 bash script.sh
:
#! /bin/sh
#################LOAD FILES###################
lead_SNPs=`grep "lead_SNPs" ../prep/files.txt | cut -f2`
bfile=`grep -w "bfile" ../prep/files.txt | cut -f2`
bfile_list=`grep -w "bfile_list" ../prep/files.txt | cut -f2`
r2=`grep "r2" ../prep/parameters.txt | cut -f2`
###############LD###########################
if [ ${bfile} = "NA" ]; then
cat ${bfile_list} | while read line; do
file=${line}
file_n=`echo $file |awk -F '/' '{print $NF}'`
echo 'Calculating LD'
plink --bfile ${file} --r2 --ld-window-kb 1000 --ld-window 999999 --ld-window-r2 ${r2} --ld-snp-list ${lead_SNPs} --out C:/Users/naghm/Desktop/FDSP-github/ld/${file_n}
done
else
file=${bfile}
file_n=`echo $file |awk -F '/' '{print $NF}'`
echo ${file_n}
plink --bfile ${file} --r2 --ld-window-kb 1000 --ld-window 999999 --ld-window-r2 ${r2} --ld-snp-list ${lead_SNPs} --out C:/Users/naghm/Desktop/FDSP-github/ld/${file_n}
fi
但是我收到这个错误
Syntax error near unexpected token `fi`
你能更正我的代码吗?我不明白我哪里弄错了。
尝试改变:
if [ ${bfile} = "NA" ]; then
到
if [ "${bfile}" = "NA" ]; then
我怀疑 ${bfile} 是空的,扩展为:
if [ = "NA" ]; then
在您的原始行中。
您脚本的第一行看起来不正确。 应该是
#!/bin/sh
或者如果使用 bash shell:
#!/bin/bash