1

all.

I have a quick question. I have a bunch of files named test01.vc, test02.vc, .., test84.vc. These are source code for a subset of c. Now I want to automatically test my compiler. So what I want to do is basically run three commands on each source file automatically. The commands are, in order:

java VC.vc testXX.vc
java jasmin.Main testXX.j
java testXX

How do I write a terminal script that does this for each file?

1

2 Answers 2

1

Create a file with the following contents

for f in `find *.vc`; do

 fn=`echo $f | cut -d'.' -f1`;
 echo "Processing ... $f";

 java VC.vc $f
 java jasmin.Main $fn.j
 java $fn

done;

Place it in the same directory as the files you want to test. Run it as a bash script, invoking it by ./Filename after you have granted it run permissions (chmod +x Filename).

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

Comments

0

I did something like this.

#!/bin/bash
# set n to 1
n=1

# continue until $n equals 5
while [ $n -le 84 ]
do
    java VC.vc testsFixed/test$n
    java jasmin.Main testsFixed/test$n.j
    java testsFixed/test$n
    n=$(( n+1 ))     # increments $n
done

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.