Rusty Lemur
Rusty Lemur

Reputation: 1885

unix diff --show-function-line truncates output

I'm working on diffing some ldif files where each section begins with "dn: leaf,branch3,branch2,branch1,root" I would like the dn (distinguished name) for each section to be displayed, and the Unix diff utility has a feature to do that: --show-function-line=regular expression. However, the diff util truncates the dn line in the output, which makes it harder to know the full path.

current command:

diff -U 0 --show-function-line="^dn\: .*" file1.ldif file2.ldif > deltas.txt

example output:

@@ -56 +56 @@ dn: administratorId=0,applicationName=pl
-previousLoginTime: 20120619180751Z
+previousLoginTime: 20120213173659Z

original dn:

dn: administratorId=0,applicationName=platform,nodeName=NODENAME

I would like the entire original line to be included in the output. Is there a way to do this?

Thanks, Rusty

Upvotes: 3

Views: 1720

Answers (1)

Rusty Lemur
Rusty Lemur

Reputation: 1885

I solved it by editing the source code and recompiling.

in src/context.c: print_context_function (FILE *out, char const *function)

changed line:

for (j = i; j < i + 40 && function[j] != '\n'; j++)

to

for (j = i; j < i + 100 && function[j] != '\n'; j++)

The "40" was limiting the number of characters output to 40, so I increased it to 100, which should be large enough for my needs. That check could probably be omitted entirely, and let it just check for function[j] != '\n', but I decided to leave it as is.

Upvotes: 2

Related Questions