Entering edit mode
23 months ago
Morta
•
0
Hi i want to rename all files with a 1 in a directory where the script is
#!/bin/bash
for filename in *.fasta; do
[ -f "$filename" ] || continue
mv "$filename" "${filename//1/}"
done
But when I'm in /tmp and the execute filename.sh the filenames have still a 1 innit
Why?
run this version; show us the output:
[root@lapt0p tmp]# bash filename.sh
Seems not to know the command fasta. How to fix it?
I can install a AUR package named fasta?! Is this command not part of the basic commands from bash?
What is your distro?
I replaced .fasta with .txt now it's editing all files with ending *.txt. I wasn't clear that the coder of this script want only modify fasta files.
How I do it if i want modifiy all files in a folder? A . instead of .txt or a simple ``?
instead of
for filename in *.fasta
, you can usefor i in *
orfor i in $(ls *)
. You can also usefind
.I wrote
not
I posted only the output of the script.
I copied one to one your new script.
what are you trying to do? You do not need a loop here. Use rename.
I did with rename but I was curious about how I do with this bashscript. I try to understand the error of the script for what I want to do.
can you try this?
But this would remove all '1's in file names.