关于在shell中直接修改文件名

在shell命令行可以直接批量修改文件名,如

chengyanchun_cfDNA1.vcf  chenyanshu_cfDNA1.vcf  chibo_WBC.vcf        gaomin_cfDNA1.vcf    huyuzhen_WBC.vcf     liudianying_cfDNA1.vcf  quhui_cfDNA2.vcf
chengyanchun_cfDNA2.vcf  chenyanshu_WBC.vcf     dingping_cfDNA1.vcf  gaomin_cfDNA2.vcf    jinliyun_cfDNA1.vcf  liudianying_cfDNA2.vcf  quhui_cfDNA3.vcf
chengyanchun_WBC.vcf     chenyan_WBC.vcf        dingping_cfDNA2.vcf  gaomin_WBC.vcf       jinliyun_cfDNA2.vcf  liudianying_WBC.vcf     quhui_WBC.vcf
chenyan_cfDNA1.vcf       chibo_cfDNA1.vcf       dingping_WBC.vcf     huyuzhen_cfDNA1.vcf  jinliyun_WBC.vcf     quhui_cfDNA1.vcf

如果将文件名中的“_”替换成"-",代码如下

 
    
ls *_* | while read line;do mv $line ${line/_/-};done
 
    
 
   

一步到位,同样,如果要添加后缀代码如下

ls *_* | while read line;do mv $line $line“.vcf”;done

 

转载于:https://www.cnblogs.com/Raymontian/p/7146193.html

你可能感兴趣的:(关于在shell中直接修改文件名)