Splunk Search

How to compare multiple files by diff command in search?

sunrise
Contributor

I have a question about diff command in search.

Of course though, a diff command compares two files,
I want to compare multiple files.
For example, when three configuration files (a.conf, b.conf, c.conf) were put into an indexer,
I want to compare those files at one search like below.

  1. Compare a.conf with b.conf
  2. Compare a.conf with c.conf
  3. Displays the each differences

Can we loop the command by reading the list file?
Any idea anyone?

Thank you.

1 Solution

dart
Splunk Employee
Splunk Employee

The presentation is not the best, but this does what you want:

index=_internal | head 3 | appendpipe [diff pos1=1 pos2=2 | eval diff = _raw]  | appendpipe [diff pos1=1 pos2=3 | eval diff= _raw] | stats values(diff)

View solution in original post

Rob
Splunk Employee
Splunk Employee

From the class

s=a OR s=b |stats count values(source) BY _raw, lineNum |search (count=1 source!=a) OR (count=2 source!=a)

dart
Splunk Employee
Splunk Employee

The presentation is not the best, but this does what you want:

index=_internal | head 3 | appendpipe [diff pos1=1 pos2=2 | eval diff = _raw]  | appendpipe [diff pos1=1 pos2=3 | eval diff= _raw] | stats values(diff)

sunrise
Contributor

Thank you dart for helping me.
I'll try it.

0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...