C-Linux-How to send C parameter value to awk script?
I'm quite new to Linux and not familiar with C. Here I have one question
about both.
I'm writing a C program to run in Linux. And I have a file names f.txt in
the same folder. With some fields like this:
Jason 12 Male
I want to compare the $2 of the txt file of each line with the value of
parameter a. If the second field of the line is greater than a, then print
the first field $1.
I tried codes like this but not work. Can anybody help? Thanks!
void main()
{ int a;
scanf("%d",&a);
char* comm="awk '{if($2>"+a+") print $1}' f.txt";
system(comm);
}
No comments:
Post a Comment