How can I write a shell script program to go through all my esql files and then execute that file to create exe files

255 views Asked by At

This is what I mean:

ls -l *.ec

For each result found, I would like to compile it one at a time.

e.g., for $something.ec:

esql $something.ec -o $something

$something.ec is original file

$something is target exe file.

My question is: how can I put that into a loop to go through all the files in my directory?

2

There are 2 answers

0
dogbane On

You can use a for-loop as follows:

for file in *.ec
do
    esql "$file" -o "${file//.ec}"
done
0
Janito Vaqueiro Ferreira Filho On

I recommend you write a simple Makefile:

INPUTS = $(wildcard *.ec)
all: $(INPUTS:.ec=)

%: %.ec
    esql $@ -o $<

and then simply run make (or make -B to force execution) whenever you want to re-execute them.