User Tools

Site Tools


cs_lang:awk

This is an old revision of the document!


Simple examples

Compare two files

{
if (ancien == FILENAME)
	A[NR] = $0
else {
	if (ok == 1)  {
		NR = 1
		ok = 0 }
	B[NR] = $0 }
}
END {printf("%s", A[2])
	for(i=0 ; i <= NR ; i++) {
		for(j=1 ; j<length(A[i]) ; j++) {
			if (substr(A[i],j,1) != substr(B[i],j,1)) {
				printf("diff : %s\t%d\t%d",substr(A[i],j,1), i, j)
			}
		}
	}
}
cs_lang/awk.1335770858.txt.gz · Last modified: 2012/04/30 09:27 by cedric