Results 1 to 2 of 2
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 ...
- 12-19-2011 #1Just Joined!
- Join Date
- Aug 2011
- Posts
- 9
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.
- 12-23-2011 #2Linux Guru
- Join Date
- May 2011
- Posts
- 1,843
As long as you wrote the C prog, why not just print i to STDOUT and j to STDERR? Then you can run it and capture output to two separate files, e.g.:
Code:testexe 1>file.out 2>file.err


Reply With Quote