我的代码在第3行给出了一条错误消息:
syntax error near unexpected token ``ARRAY1=$(awk 'FNR == 1{print $2}' $file)
set -vx
for file in ls bowtie-0.12.7-win32/bowtie-0.12.7/Hits_635_25bp/*.txt
ARRAY1=$(awk 'FNR == 1{print $2}' $file) # stores the value
let ARRAY1=$ARRAY1/100+1
echo $ARRAY1
value1=$(awk 'FNR == '$ARRAY1'{print $1}' bowtie-0.12.7-win32/bowtie-0.12.7/list_for_635_fasta.list) # GETS THE VALUES FROM THE LIST
echo $value1
value2=$(awk 'FNR == 1{print $2,$3,$4,$5,$6,$7}' bwa-0.5.9/bwa-0.5.9/GENOMES/${file:0:13}) # GETS THE VALUES FROM THE LIST
echo $value2
done
如果有人能指出错误,我会很感激。这似乎有道理,但我想我错过了什么。
答案 0 :(得分:1)
for file in ls bowtie-0.12.7-win32/bowtie-0.12.7/Hits_635_25bp/*.txt
上面的行应该是
for file in `ls bowtie-0.12.7-win32/bowtie-0.12.7/Hits_635_25bp/*.txt`
do
答案 1 :(得分:1)
试试这个:
set -vx
for file in bowtie-0.12.7-win32/bowtie-0.12.7/Hits_635_25bp/*.txt; do
ARRAY1=$( awk 'FNR == 1 { print $2 }' "$file" )
let ARRAY1=$ARRAY1/100+1
echo "$ARRAY1"
value1=$( awk -v a1="$ARRAY1" 'FNR == a1 { print $1 }' bowtie-0.12.7-win32/bowtie-0.12.7/list_for_635_fasta.list )
echo "$value1"
value2=$( awk 'FNR == 1 { print $2, $3, $4, $5, $6, $7 }' bwa-0.5.9/bwa-0.5.9/GENOMES/"${file:0:13}" )
echo "$value2"
done
如果你告诉我们你正在使用什么shell,我们可以改进代码。