0

I'm so new to shell scripts. I'd really appreciate if anyone can help please.

I have a Fortran code, consisting of a program and three subroutines that correct a certain line of a file (with .pol extension) using a .txt file, by the following commands in Linux Ubuntu terminal:

gfortran -c FirstSubroutine.f90
gfortran -c SecondSubroutine.f90
gfortran -c ThirdSubroutine.f90

gfortran FirstSubroutine.o FirstSubroutine.o FirstSubroutine.o  MainProgram.f90 -o exeFileName

./exeFileName Path1 .polFileToBeModified Path2

In which Path1 is the folder where all input files (including .pol and .txt files) are and Path2 is the folder in which all output files are desired to be saved.

The question is: "How can I write a shell script that does this process for many input files?"

1

1 Answer 1

1

Your question is not entirely clear, but if you have a bunch of files in Path1, you probably just need either:

for file in Path1/*.pol; do ./exeFileName Path1 $file Path2; done

or

for file in Path1/*.pol; do ./exeFileName Path1 ${file#Path1/} Path2; done

depending on if you want the relative path of the file or just the basename.

Sign up to request clarification or add additional context in comments.

Comments

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.