how I can rename several files (Q0138-9061933666_S5.fasta.db) in a folder and leave only the no as ca (Q0138-9061933666_S5.db) i.e. delete .fasta from all files
Asked
Active
Viewed 47 times
1 Answers
0
Assuming you are in the folder where the files are placed.
for i in *.fasta.db
do
mv $i ${i/\.fasta/} # remove "fasta" from file name
done
See Replace one substring for another string in shell script for details about string substitution

flappix
- 2,038
- 17
- 28
-
Thank you very much, I have another question, how can I replace the character (-) by (_) for all the files and thank you in advance. – ABDELJALIL SENHAJI RACHIK Apr 20 '20 at 13:27
-
add a second string substitution in the loop ```mv $newfile ${newfile/-/_}``` – flappix Apr 20 '20 at 16:22