<?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: eval, if, len, substr to produce specific results in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/eval-if-len-substr-to-produce-specific-results/m-p/488411#M136445</link>
    <description>&lt;P&gt;@noob4now,&lt;/P&gt;

&lt;P&gt;Try using nested if&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval Port=if(match(Port,"Ethernet"),if(len(Port)&amp;gt;=22,substr(Port,1,len(Port)-2),Port),Port)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 21 Sep 2019 08:46:42 GMT</pubDate>
    <dc:creator>renjith_nair</dc:creator>
    <dc:date>2019-09-21T08:46:42Z</dc:date>
    <item>
      <title>eval, if, len, substr to produce specific results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/eval-if-len-substr-to-produce-specific-results/m-p/488410#M136444</link>
      <description>&lt;P&gt;So far, I've had success with the following command:&lt;BR /&gt;
    eval Port=if(len(Port)&amp;gt;=22,substr(Port,1,len(Port)-2),Port)&lt;BR /&gt;
This checks to see if a Sport result is &amp;gt;= 22, then subtracts 2 characters from the end. I get good results but they need to be specific to a particular search result. &lt;/P&gt;

&lt;P&gt;The output I'm concerned with specifically is "Ethernet%" and everything else should be left alone by the above statement. I'm sure this is a simple fix, but I can't quite figure out how to put it all togehter...&lt;/P&gt;

&lt;P&gt;I'm thinking it should start with:&lt;BR /&gt;
    eval Port=if(Port="Ethernet%"  &amp;lt;--- from here, I'm a bit lost on how to put it together with the above statement.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Sep 2019 14:25:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/eval-if-len-substr-to-produce-specific-results/m-p/488410#M136444</guid>
      <dc:creator>noob4now</dc:creator>
      <dc:date>2019-09-20T14:25:37Z</dc:date>
    </item>
    <item>
      <title>Re: eval, if, len, substr to produce specific results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/eval-if-len-substr-to-produce-specific-results/m-p/488411#M136445</link>
      <description>&lt;P&gt;@noob4now,&lt;/P&gt;

&lt;P&gt;Try using nested if&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval Port=if(match(Port,"Ethernet"),if(len(Port)&amp;gt;=22,substr(Port,1,len(Port)-2),Port),Port)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 21 Sep 2019 08:46:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/eval-if-len-substr-to-produce-specific-results/m-p/488411#M136445</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2019-09-21T08:46:42Z</dc:date>
    </item>
  </channel>
</rss>

