我正在尝试迭代目录中的文件。该目录包含文件。
{3-23*01.fastq, 3-23D*01.fastq,3-23*02.fastq,3-23*03.fastq,3-23*04.fastq,3-23D*01.fastq,3-30*01.fastq 3-30-3*01.fastq,3-30*02.fastq,3-30-3*02.fastq,3-30*03.fastq,3-30-3*03.fastq}但是,由于某种原因,当我像下面的For循环一样迭代这些文件时,它会跳过一些文件吗?或者认为两个文件实际上是一个?我不太确定到底怎么回事。
for PATH_TO_FILE in *; do
echo $PATH_TO_FILE
echo "hello"
done输出:
3-23*01.fastq 3-23D*01.fastq
hello
3-23*02.fastq
hello
3-23*03.fastq
hello
3-23*04.fastq
hello
3-23D*01.fastq
hello
3-30*01.fastq 3-30-3*01.fastq
hello
3-30*02.fastq 3-30-3*02.fastq
hello
3-30*03.fastq 3-30-3*03.fastq发布于 2015-06-28 10:28:05
在打印时引用变量,以避免文件名为文件名中的*:
for PATH in *; do
echo "$PATH"
echo "hello"
donePATH可能不是正确的变量名,因为您将丢失shell的PATH。
https://stackoverflow.com/questions/31098622
复制相似问题