dimanche 30 novembre 2014

get only file name while iterating over directory instead of path with it


script.sh -i /storage/testFile


-i is stores path of /storage/testFile/


I want to iterate over file in testFile. Everything goes good, but I want to make this code more clean, add directory for output and other checks.


A snippet of my code is


for f in $inDir/*.vcf; do if [ -f $f ]; #check if file is true or exists then if [ ${f: -4} == ".vcf" ] # check if the file ends with .vcf then convert2annovar.pl -format vcf4 "$f" > ./"$f".avinput #run my code fi fi done


Issue:


echo $f I get /storage/testFiles/test.vcf


How do I get only test.vcf while I iterate in for loop?



Aucun commentaire:

Enregistrer un commentaire