Monday 19 December 2011

Getting the output seperately in 2 terminals simultaneously

Getting the output seperately in 2 terminals simultaneously

Hai I have written a c program
test.c
#include<stdio.h>
main()
{
int i,j;
for(i=1,j=10;i,j;i++,j++)
{

printf("%d\n",i);
printf("%d\n",j);

sleep(1);
}
}

the output comes like this and it is for infinite loop
./testexe
1
10
2
11
3
12
4
13
5
14
6
15
7
16
..................so on;

after that I am putting the output into a file by executing shell script

#!/bin/bash
./testexe>file1

now I need to get the values of i in one terminal like

1
2
3
4
........so on;

and I need to get values of j to be put in another terminal like

10
11
12
13
14
..........so on;

Please help me get this.(so total of 3 terminals are opened)

I tried writing script for getting i values

#!/bin/bash
echo "Executing the program"
i=1
for(( ; ; ))
do
i=$i+1
awk 'NR==$i {print}' file1
done

but i am not getting any output.

No comments:

Post a Comment