I am trying to do this

#!/bin/bash

for i in 1 2 3 4 5; do 
	File1="$i.txt"
	File2="$i.obj"
	./Test $File1 $File2
 #save i and the result of the program somehow
done;

For example, at the end I would like to have a file like this

1 3.4
2 4.55
3 56.0
4 22.3
5 8.9

Where the second column is the "output" of the c++ program. The problem is the program has other outputs, ie

Starting program....
Doing stuff ....
3.4

Anyone ever wrap a program in a loop like this before and care about saving the output?

Thanks,
Dave

Filter the output with grep: ./Test "$i.txt" "$i.obj" | grep -vi '^[:alpha:]' Perl's good for this:

for $i (1..5) {
  for (`./Test $i.txt $i.obj`) {
    next if /^\s*\w/;
    print;
  }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.