Reputation: 1
I'm writing a code in C and I'm trying to use 3 commands (echo
, grep
and wc
) with excev()
but its not working.
It is possible to do it and if not any other solution or I will need to use fscanf()
.
How I want it to print in bash: code in bash
The code I wrote in C, which is not working:
void count_lines(short unsigned int G)
{
g = 0;
while (g <= G) {
char *const command[] = {"echo","Number of lines by processes of generation",g,"is","`grep","-o","G is",g,"out.txt","|","wc","-l",NULL };
execv("/bin/echo /usr/grep bin/wc", command);
g++
}
}
Upvotes: 0
Views: 38