我是 Bash 脚本的新手。我必须在这里比较两个值,$i 和 $cdsStart:检查 $i 是否小于 $cdsScript,下面是我执行相同操作的代码。
inputFile="$1"
while read -r transcriptName chromosomeNum strand transcriptStart transcriptEnd cdsStart cdsEnd numExons exSt exEnd rest ;
do
if [ "$transcriptName" == "ENST00000359033" ]
then
exonStart=$(echo "$exSt" | egrep -o '[0-9]+')
exonEnd=$(echo "$exEnd" | egrep -o '[0-9]+')
echo "exon-start: $exonStart"
echo "exon-end: $exonEnd"
for i in "$exonStart"
do
if (( "$i" -lt "$cdsStart" )) ##this does not work
then
echo "value: $i"
fi
done
fi
done < "$inputFile"
它只是报告“表达式中的语法错误”,有人能告诉我如何调试它吗?
谢谢
答案1
有人能告诉我如何调试这个吗?
$ shellcheck myscript
Line 1:
inputFile="$1"
^-- SC2148: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
Line 2:
while read -r transcriptName chromosomeNum strand transcriptStart transcriptEnd cdsStart cdsEnd numExons exSt exEnd rest ;
^-- SC2034: chromosomeNum appears unused. Verify use (or export if used externally).
^-- SC2034: strand appears unused. Verify use (or export if used externally).
^-- SC2034: transcriptStart appears unused. Verify use (or export if used externally).
>> ^-- SC2034: transcriptEnd appears unused. Verify use (or export if used externally).
>> ^-- SC2034: cdsEnd appears unused. Verify use (or export if used externally).
>> ^-- SC2034: numExons appears unused. Verify use (or export if used externally).
Line 6:
exonStart=$(echo "$exSt" | egrep -o '[0-9]+')
^-- SC2196: egrep is non-standard and deprecated. Use grep -E instead.
Line 7:
exonEnd=$(echo "$exEnd" | egrep -o '[0-9]+')
^-- SC2196: egrep is non-standard and deprecated. Use grep -E instead.
Line 11:
for i in "$exonStart"
^-- SC2066: Since you double quoted this, it will not word split, and the loop will only run once.
Line 13:
if (( "$i" -lt "$cdsStart" )) ##this does not work
^-- SC1105: Shells disambiguate (( differently or not at all. For subshell, add spaces around ( . For ((, fix parsing errors.
^-- SC2205: (..) is a subshell. Did you mean [ .. ], a test expression?
^-- SC1106: In arithmetic contexts, use < instead of -lt