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種.