![쉘 스크립트를 호출할 때 매개변수를 어떻게 전달합니까?](https://linux55.com/image/80554/%EC%89%98%20%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8%EB%A5%BC%20%ED%98%B8%EC%B6%9C%ED%95%A0%20%EB%95%8C%20%EB%A7%A4%EA%B0%9C%EB%B3%80%EC%88%98%EB%A5%BC%20%EC%96%B4%EB%96%BB%EA%B2%8C%20%EC%A0%84%EB%8B%AC%ED%95%A9%EB%8B%88%EA%B9%8C%3F.png)
#!/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
루프를 선언할 때 bash를 사용하면 for i in {ls*.fastq} # trying to run batch processing
이전에 값을 할당하지 않았기 때문에 공백으로 대체되기 때문에 으로 변경해야 합니다 .$i
$i