I have created a simple c program and have left off a ';' on purpose to get an error. I want using the grep command to know whether the compilation was successful or not.
I use:
gcc test.c | grep 'error'
but the output does not seem right. Is this the right way ?
I am supposing it does not work because by doing:
echo "hello world" | grep "hello"
I get a coloured text for the match.
When doing grep for compilation there is no such thing.
The error has this form:
test.c: In function ‘main’:
test.c:8:2: error: expected ‘,’ or ‘;’ before ‘return’
return 0;
^
and the program I use is :
int main(int argc, char const *argv[]){
char f[] = "Hello thereeee!"
return 0;
}
Error
with a capital?gcc ... |& grep
.