1

I have some code that is used to analyse files, the code is setup to analyse 1 file at a time using the following command line input in the /home/john/Dropbox/PhD/MultiFOLDIA/ directory:

java MultiFOLDIA_IMODE1 complex.1.pdb /home/john/Dropbox/PhD/MultiFOLDIA/Poses/ T0868_T0869 /home/john/Dropbox/PhD/MultiFOLDIA/T0868_T0869_complex.1.pdb_IMODE1.txt > /home/john/Dropbox/PhD/MultiFOLDIA/MultiFOLDIA_IMODE1.log

I would like to run the command on every file in the /home/john/Dropbox/PhD/MultiFOLDIA/Poses/ directory and have tried using the following script:

#!/bin/bash

poses=(~/home/john/Dropbox/PhD/MultiFOLDIA/Poses/*)

for f in "${poses[@]}"; do
java MultiFOLDIA_IMODE1 "$f" /home/john/Dropbox/PhD/MultiFOLDIA/Poses/ T0868_T0869 /home/john/Dropbox/PhD/MultiFOLDIA/T0868_T0869_"$f"_IMODE1.txt > /home/john/Dropbox/PhD/MultiFOLDIA/MultiFOLDIA_IMODE1.log
done

It doesn't work and I think I am not understanding how to pull filenames from arrays and utilise them in this way.

0

2 Answers 2

1

~/ is already /home/john.

So ~/home/john probably doesn't exist.

This should bring you closer to your goal :

cd /home/john/Dropbox/PhD/MultiFOLDIA/Poses/

for pdb in *.pdb
do
  echo "Processing $pdb"
  java MultiFOLDIA_IMODE1 "$pdb" ./ T0868_T0869 ../T0868_T0869_"$pdb"_IMODE1.txt >> ../MultiFOLDIA_IMODE1.log
done
Sign up to request clarification or add additional context in comments.

2 Comments

Hurrah this worked, now to educate myself as to why it works ;) Thank you Eric
Is there something you don't understand in particular?
1

This should work.

find /home/john/Dropbox/PhD/MultiFOLDIA/Poses/ -maxdepth 1 -type f -exec java MultiFOLDIA_IMODE1 '{}' /home/john/Dropbox/PhD/MultiFOLDIA/Poses/ T0868_T0869 /home/john/Dropbox/PhD/MultiFOLDIA/T0868_T0869_'{}'_IMODE1.txt >> /home/john/Dropbox/PhD/MultiFOLDIA/MultiFOLDIA_IMODE1.log \; 

Also, when redirecting output use >> instead of >. > truncate file and in the end you will have only logs from last execution eg:

$ echo a > test.txt
$ echo a > test.txt
$ cat test.txt
a

$ echo a >> test.txt
$ echo a >> test.txt
$ cat test.txt
a
a

3 Comments

This won't work like this. You should remove -path and you're trying to use an undefined "$f".
True that, I missed this "$f"
Thanks for the tip about redirecting output, very useful.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.