调用shell脚本时如何传递参数?

调用shell脚本时如何传递参数?
#!/bin/bash

./bbmap.sh ref=ref.fa # creating index file from the input  

for $i in {ls*.fastq} # trying to run batch processing 
do
    ./bbmap.sh in=$i out={.}
done

它说:

BBMap version 35.74
Retaining first best site only for ambiguous mappings.
No output file.
NOTE:   Ignoring reference file because it already appears to have been processed.
NOTE:   If you wish to regenerate the index, please manually delete ref/genome/1/summary.txt
Set genome to 1

Loaded Reference:   3.390 seconds.
Loading index for chunk 1-2, build 1
Generated Index:    1.011 seconds.
No reads to process; quitting.

Total time:         4.443 seconds.
TestScript.sh: line 6: `$i': not a valid identifier

答案1

在命令行上传递它们,并在脚本中使用 、 等$1引用它们。$2

答案2

您应该更改for $i in {ls*.fastq} # trying to run batch processing为,因为通过在声明循环时for i in {ls*.fastq} # trying to run batch processing使用, bash 会替换为空格,因为您之前没有为其分配值。$i$i

相关内容