我想从工具运行命令来合并我的文件
http://snpeff.sourceforge.net/SnpSift.html#Split
java -jar ~/snpEff_latest_core/snpEff/SnpSift.jar split -j file1.vcf file2.vcf file3.vcf ... > huge.out.vcf
我有 400 多个文件,所以一个一个地输入可能是错误的。
我试过这样的东西
find -name "*.vcf" | java -jar ~/snpEff_latest_core/snpEff/SnpSift.jar split -j > comb.vcf
这是我遇到的错误
Error: Cannot 'join' less than two files.
SnpSift split -j
SnpSift version 4.1k (build 2015-09-07), by Pablo Cingolani
Usage: java -jar SnpSift.jar splitChr [-j] [-l <num>] file.vcf [file_2.vcf ... file_N.vcf]
Options:
-j : Join all files in command line (output = STDOUT).
-l <num> : Split by 'num' lines.
Default : Split by chromosome (one file per chromosome).
我在其他工具上使用过这个“find -name”,它似乎有效。
所以我的问题是,如何选择目录中的所有文件并运行命令。
最佳答案
你可以试试:
java -jar ~/snpEff_latest_core/snpEff/SnpSift.jar split -j file*.vcf
Bash 会将文件*.vcf 展开为当前目录中与文件*.vcf 匹配的所有文件。
请注意 linux 对命令的长度有最大限制(大约 3MB)。
如果你想使用查找(给你更细粒度的选择),你可以使用这样的东西:
find . -exec java -jar ~/snpEff_latest_core/snpEff/SnpSift.jar split -j {} \+
这里的“{}”替换为find找到的文件,\+表示:
the -exec action runs the specified command on the selected files, but the command line is built by appending each selected file name at the end
关于linux - 如何选择目录中的所有文件并运行命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33645375/