<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: distinct first n characters of string in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/distinct-first-n-characters-of-string/m-p/451656#M191252</link>
    <description>&lt;P&gt;It worked!!!!!!! Thank you!!!!!&lt;/P&gt;</description>
    <pubDate>Thu, 15 Aug 2019 18:08:26 GMT</pubDate>
    <dc:creator>reverse</dc:creator>
    <dc:date>2019-08-15T18:08:26Z</dc:date>
    <item>
      <title>distinct first n characters of string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/distinct-first-n-characters-of-string/m-p/451650#M191246</link>
      <description>&lt;P&gt;Lets say .. My result would produce &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;a.log
a.log.1
a.log.2
a.log.3
b.log
b.log.1
b.log.2
b.log.3
c.log
c.log.1
c.log.2
c.log.3 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I want the final result as &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;a.log
b.log
c.log
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thoughts ?&lt;/P&gt;</description>
      <pubDate>Thu, 15 Aug 2019 17:19:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/distinct-first-n-characters-of-string/m-p/451650#M191246</guid>
      <dc:creator>reverse</dc:creator>
      <dc:date>2019-08-15T17:19:15Z</dc:date>
    </item>
    <item>
      <title>Re: distinct first n characters of string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/distinct-first-n-characters-of-string/m-p/451651#M191247</link>
      <description>&lt;P&gt;are these fields or values?&lt;/P&gt;</description>
      <pubDate>Thu, 15 Aug 2019 17:21:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/distinct-first-n-characters-of-string/m-p/451651#M191247</guid>
      <dc:creator>mayurr98</dc:creator>
      <dc:date>2019-08-15T17:21:43Z</dc:date>
    </item>
    <item>
      <title>Re: distinct first n characters of string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/distinct-first-n-characters-of-string/m-p/451652#M191248</link>
      <description>&lt;P&gt;@mayurr98 · these are values&lt;/P&gt;</description>
      <pubDate>Thu, 15 Aug 2019 17:22:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/distinct-first-n-characters-of-string/m-p/451652#M191248</guid>
      <dc:creator>reverse</dc:creator>
      <dc:date>2019-08-15T17:22:11Z</dc:date>
    </item>
    <item>
      <title>Re: distinct first n characters of string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/distinct-first-n-characters-of-string/m-p/451653#M191249</link>
      <description>&lt;P&gt;Try this run anywhere search&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults | eval field1="a.log a.log1 a.log2 a.log3 " | makemv field1 | mvexpand field1 | appendcols [| makeresults | eval field2="b.log b.log1 b.log2 b.log3 " | makemv field2 | mvexpand field2] | replace a.log* WITH a.log IN field1 | replace b.log* WITH b.log IN field2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Try &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;| replace a.log* WITH a.log IN fieldname| replace b.log* WITH b.log IN fieldname | so on&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;replace documentation:&lt;BR /&gt;
&lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Replace"&gt;https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Replace&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;OR another way is &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|eval field1=replace(field1,"(a.log).*","\1"), field2=replace(field2,"(b.log).*","\1"), so on
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 15 Aug 2019 17:27:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/distinct-first-n-characters-of-string/m-p/451653#M191249</guid>
      <dc:creator>mayurr98</dc:creator>
      <dc:date>2019-08-15T17:27:13Z</dc:date>
    </item>
    <item>
      <title>Re: distinct first n characters of string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/distinct-first-n-characters-of-string/m-p/451654#M191250</link>
      <description>&lt;P&gt;but this wont help as there are 70 varieties of logs &lt;/P&gt;</description>
      <pubDate>Thu, 15 Aug 2019 17:38:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/distinct-first-n-characters-of-string/m-p/451654#M191250</guid>
      <dc:creator>reverse</dc:creator>
      <dc:date>2019-08-15T17:38:50Z</dc:date>
    </item>
    <item>
      <title>Re: distinct first n characters of string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/distinct-first-n-characters-of-string/m-p/451655#M191251</link>
      <description>&lt;P&gt;Try something like this..&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults | eval field1="a.log a.log1 a.log2 a.log3 " | makemv field1 | mvexpand field1 | appendcols [| makeresults | eval field2="b.log b.log1 b.log2 b.log3 " | makemv field2 | mvexpand field2] | table field1 field2| foreach field* [eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;=replace(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;,"^(\w+)(.log).*","\1\2")]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will do for each and every  fields&lt;CODE&gt;field*&lt;/CODE&gt; &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;| foreach field* [eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;=replace(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;,"^(\w+)(.log).*","\1\2")]&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Aug 2019 18:01:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/distinct-first-n-characters-of-string/m-p/451655#M191251</guid>
      <dc:creator>mayurr98</dc:creator>
      <dc:date>2019-08-15T18:01:53Z</dc:date>
    </item>
    <item>
      <title>Re: distinct first n characters of string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/distinct-first-n-characters-of-string/m-p/451656#M191252</link>
      <description>&lt;P&gt;It worked!!!!!!! Thank you!!!!!&lt;/P&gt;</description>
      <pubDate>Thu, 15 Aug 2019 18:08:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/distinct-first-n-characters-of-string/m-p/451656#M191252</guid>
      <dc:creator>reverse</dc:creator>
      <dc:date>2019-08-15T18:08:26Z</dc:date>
    </item>
  </channel>
</rss>

