The problem:
Hi, I'm trying to loop over each *.faa file in multiple directories (e.g. /path/to/*.faa)
And then, using a script (./script.py) as if the script was in the same directory as the *.faa file, is this possible with shellscript?
What I've tried:
for FAA in $(find . -name "*.faa")
do
cd ../$FAA
python3 ../script.py
done
I've tried variations on this, but changing to the directory to a file doesn't work, but I don't know a way of getting to that directory.
Desired output:
For each .faa file, in multiple directories e.g /path/to/1.faa, path/2/2.faa, run the script in the directory two levels above. As if it were in the same directory as each of the *.faa files, or if that's not possible, what is the best solution to achieving something similar?
/some/path/to/foo.faa
, what directory do you want to go to run the script? – ilkkachu Jul 06 '18 at 10:07/some/path/script.py
that should be the one that runs for/some/path/to/foo.faa
? – ilkkachu Jul 06 '18 at 10:09script.py
will need to change (./
or../
or../../
, etc.). Can you provide an absolute path to the script please. (At least, an example one.) – Chris Davies Jul 06 '18 at 10:09