2
我試圖使用bash
來重命名與特定模式匹配的目錄中的所有.txt
文件。我下面的兩個嘗試從目錄中刪除了這些文件並拋出一個錯誤。謝謝:)重命名目錄中的特定類型的所有文件
輸入
16-0000_File-A_variant_strandbias_readcount.vcf.hg19_multianno_dbremoved_removed_final_index_inheritence_import.txt
16-0002_File-B_variant_strandbias_readcount.vcf.hg19_multianno_dbremoved_removed_final_index_inheritence_import.txt
所需的輸出
16-0000_File-A_multianno.txt
16-0002_File-B_multianno.txt
猛砸試圖1 this removes the files from the directory
for f in /home/cmccabe/Desktop/test/vcf/overall/annovar/*_classify.txt ; do
# Grab file prefix.
p=${f%%_*_}
bname=`basename $f`
pref=${bname%%.txt}
mv "$f" ${p}_multianno.txt
done
猛砸試圖2 Substitution replacement not terminated at (eval 1) line 1.
for f in /home/cmccabe/Desktop/test/vcf/overall/annovar/*_classify.txt ; do
# Grab file prefix.
p=${f%%_*_}
bname=`basename $f`
pref=${bname%%.txt}
rename -n 's/^$f/' *${p}_multianno.txt
done
非常感謝您的幫助和解釋,我非常感謝他們:) – Chris