linux PATH环境变量 中 相同变量名的调用优先级
测试 使用plink v1.07 和 plink v1.9两个软件版本进行测试
001、将plink v1.07 的变量放在 plink v1.9之前, 观测系统调用的plink版本
[liujiaxin01@PC1 ~]$ echo $PATH ## 输出当前的PATH变量 /home/liujiaxin01/anaconda3/condabin:/home/liujiaxin01/.local/bin:/home/liujiaxin01/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/software/gatk-4.1.9.0:/home/software/picard [liujiaxin01@PC1 ~]$ PATH=/home/liujiaxin01/anaconda3/condabin:/home/liujiaxin01/.local/bin:/home/liujiaxin01/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/software/gatk-4.1.9.0:/home/software/picard:/home/liujiaxin01/software/plink17:/home/liujiaxin01/software/plink19 [liujiaxin01@PC1 ~]$ plink ## 将plink1.07变量放在plink1.9之前, 调用plink测试, 发现调用起来的是plink v1.07 @----------------------------------------------------------@ | PLINK! | v1.07 | 10/Aug/2009 | |----------------------------------------------------------| | (C) 2009 Shaun Purcell, GNU General Public License, v2 | |----------------------------------------------------------| | For documentation, citation & bug-report instructions: | | http://pngu.mgh.harvard.edu/purcell/plink/ | @----------------------------------------------------------@ Web-based version check ( --noweb to skip ) Connecting to web... ^C
002、调换 plinkv1.07和plink1.9的顺序, 即plinkv1.9变量放在plinkv1.07之前,观察系统调用的优先级
[liujiaxin01@PC1 ~]$ echo $PATH ## 输出当前的PATH变量内容 /home/liujiaxin01/anaconda3/condabin:/home/liujiaxin01/.local/bin:/home/liujiaxin01/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/software/gatk-4.1.9.0:/home/software/picard:/home/liujiaxin01/software/plink17:/home/liujiaxin01/software/plink19 [liujiaxin01@PC1 ~]$ PATH=/home/liujiaxin01/anaconda3/condabin:/home/liujiaxin01/.local/bin:/home/liujiaxin01/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/software/gatk-4.1.9.0:/home/software/picard:/home/liujiaxin01/software/plink19:/home/liujiaxin01/software/plink17 [liujiaxin01@PC1 ~]$ echo $PATH ## 将变量plinkv1.9 放在plinkv1.07之前, 并输出PATH变量 /home/liujiaxin01/anaconda3/condabin:/home/liujiaxin01/.local/bin:/home/liujiaxin01/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/software/gatk-4.1.9.0:/home/software/picard:/home/liujiaxin01/software/plink19:/home/liujiaxin01/software/plink17 [liujiaxin01@PC1 ~]$ plink ## 测试系统调用的优先级, 调用plinv1.9 PLINK v1.90b6.27 64-bit (10 Dec 2022) www.cog-genomics.org/plink/1.9/ (C) 2005-2022 Shaun Purcell, Christopher Chang GNU General Public License v3 plink <input flag(s)...> [command flag(s)...] [other flag(s)...] plink --help [flag name(s)...] Commands include --make-bed, --recode, --flip-scan, --merge-list, --write-snplist, --list-duplicate-vars, --freqx, --missing, --test-mishap, --hardy, --mendel, --ibc, --impute-sex, --indep-pairphase, --r2, --show-tags, --blocks, --distance, --genome, --homozyg, --make-rel, --make-grm-gz, --rel-cutoff, --cluster, --pca, --neighbour, --ibs-test, --regress-distance, --model, --bd, --gxe, --logistic, --dosage, --lasso, --test-missing, --make-perm-pheno, --tdt, --qfam, --annotate, --clump, --gene-report, --meta-analysis, --epistasis, --fast-epistasis, and --score. "plink --help | more" describes all functions (warning: long).
小结:当PATH环境变量中存在相同的变量名时, 系统优先调用PATH变量名中最前面的那个变量。