0

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

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by nucleon
0

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;
  }
}
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.