Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个包含许多文件的文件夹txt,我想应用for do do循环将它们从文件转换txt为biom文件,以下是我所做的:
txt
for do do
biom
for txt in folder/*.txt do biom convert -i $txt -o *.biom --to-hdf5 done
但我得到了一个组合的 biom 文件。
如何修改上面的代码,将多个 txt 文件更改为 biom 文件,而不更改原始文件名?
喜欢:test.txt到test.biom
test.txt
test.biom
以下应该可以解决问题(假设文件名中现在有空格):
for txt in folder/*.txt do biom convert -i $txt -o ${txt%.txt}.biom --to-hdf5 done
bash 替换${txt%.txt}删除.txt了变量,我们.biom在最后添加。
${txt%.txt}
.txt
.biom