这里的初学者正在尝试在bash中使用管道。如果有人知道原因,当我运行以下命令时,我会得到:
-bash: `$i': not a valid identifier,这将是非常有帮助的。另外,如果还有其他错误,请让我知道
for $i in /home/regionstextfile; do tabix /sequences/human_variation/snps/genotypes.vcf.gz $i | vcftools --window-pi 10000 >> /home/Testgenomesdata/genomesregions.txt; done其思想是对于regionstextfile (包含基因组坐标)中的每一行,在vcf.bz文件中运行一个名为tabix的程序,然后使用输出运行带有指定选项的vcftools,然后将所有输出放入genomesregions.txt文件中。
发布于 2012-06-19 15:37:56
肯定是这样的:
for i in `</home/regionstextfile`
do
tabix /sequences/human_variation/snps/genotypes.vcf.gz $i | vcftools --window-pi 10000 >> /home/Testgenomesdata/genomesregions.txt
done当你使用一个变量(例如,给它赋值或导出它,或者对变量本身做任何事情)时,你写的是不带$的名称;当你使用一个变量的值时,你写的是$。
编辑:
如果区域名称包含空格,但每个区域位于单独的行中,则需要while
cat /home/regionstextfile | while read i
do
tabix /sequences/human_variation/snps/genotypes.vcf.gz "$i" | vcftools --window-pi 10000 >> /home/Testgenomesdata/genomesregions.txt
done发布于 2012-06-19 17:49:01
没有cat也是一样的:
while read i
do
tabix /sequences/human_variation/snps/genotypes.vcf.gz "$i" | vcftools --window-pi 10000 >> /home/Testgenomesdata/genomesregions.txt
done < /home/regionstextfile备注:除非<file.txt =‘’,否则无法工作
OLDIFS="$IFS"
IFS=''
for i in `</home/regionstextfile`
do
tabix /sequences/human_variation/snps/genotypes.vcf.gz $i | vcftools --window-pi 10000 >> /home/Testgenomesdata/genomesregions.txt
done
IFS="$OLDIFS"https://stackoverflow.com/questions/11096412
复制相似问题