hello.c
#include <stdio.h>
int main(void)
{
char msg[ ] =
"Hello Linux programmer!";
puts(msg);
printf("Here you are, using
diff.\n");
return 0;
}
howdy.c
#include
<stdio.h>
#include <stdlib.h>
int main(void)
{
char
msg[ ] = "Hello, linux programmer, from
howdy.c";
puts(msg);
printf("howdy.c says, 'Here you are using
diff.'\n");
exit(EXIT_SUCCESS);
}
使用diff的基本语法产生的输出(在下面"理解正规输出格式"部分所介绍的为正规格式)是:
$diff
hello.c howdy.c
la2
> #include <stdlib.h>
5c6
< char
msg[ ] = "Hello, Linux programmer!";
---
> char msg[ ] = "Hello,
Linux programmer, from howdy.c!";
8c9
< printf("Here you are, using
diff.\n");
---
> printf("howdy.c says, 'Here you are, using
diff.'\n");
10c11
< return 0;
---
>
exit(EXIT_SUCCESS);
diff能够产生几种输出格式,包括正规(normal,也是diff默认的市场格式),上下文(context),统一(unified)以及并排(side-by-side)4种.