<?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: extract basename from path in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/extract-basename-from-path/m-p/203097#M187604</link>
    <description>&lt;P&gt;@somesoni2 provides a much better regex (unsurprisingly) and also that would work for any file extension. I will now go ahead and drown in my sorrow.&lt;/P&gt;</description>
    <pubDate>Fri, 12 Feb 2016 23:00:25 GMT</pubDate>
    <dc:creator>sk314</dc:creator>
    <dc:date>2016-02-12T23:00:25Z</dc:date>
    <item>
      <title>extract basename from path</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-basename-from-path/m-p/203094#M187601</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
Im trying to extract basename that's is &lt;CODE&gt;abc.log&lt;/CODE&gt; from the below&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;D:\Program Files\User\abc.log
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;using &lt;CODE&gt;| eval source= replace(source, ".*/", "")&lt;/CODE&gt; &lt;BR /&gt;
or &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval source= replace(source, ".*\.", "") 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;but this is printing the full path. can you please suggest a solution&lt;/P&gt;</description>
      <pubDate>Fri, 12 Feb 2016 22:05:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-basename-from-path/m-p/203094#M187601</guid>
      <dc:creator>deenadp</dc:creator>
      <dc:date>2016-02-12T22:05:25Z</dc:date>
    </item>
    <item>
      <title>Re: extract basename from path</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-basename-from-path/m-p/203095#M187602</link>
      <description>&lt;P&gt;You should try Field Extractionsin Splunk : &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.0/Knowledge/ExtractfieldsinteractivelywithIFX"&gt;http://docs.splunk.com/Documentation/Splunk/6.2.0/Knowledge/ExtractfieldsinteractivelywithIFX&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;For the example, you could try something like this:&lt;/P&gt;

&lt;P&gt;|   &lt;CODE&gt;rex field=source "(?&amp;lt;=\\\)(?[^\\\]+(?=.log).log)"&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Feb 2016 22:52:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-basename-from-path/m-p/203095#M187602</guid>
      <dc:creator>sk314</dc:creator>
      <dc:date>2016-02-12T22:52:31Z</dc:date>
    </item>
    <item>
      <title>Re: extract basename from path</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-basename-from-path/m-p/203096#M187603</link>
      <description>&lt;P&gt;Try any of these (first line is to generate the dummy rows, replace it with your search)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| gentimes start=-1 | eval source="D:\Program Files\User\abc.log" | table source 
| rex field=source "\\\(?&amp;lt;filename&amp;gt;\w+\.\w+)$" 
| eval filename2=replace(source,"([^\\\]+\\\)","")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 12 Feb 2016 22:52:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-basename-from-path/m-p/203096#M187603</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-02-12T22:52:43Z</dc:date>
    </item>
    <item>
      <title>Re: extract basename from path</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-basename-from-path/m-p/203097#M187604</link>
      <description>&lt;P&gt;@somesoni2 provides a much better regex (unsurprisingly) and also that would work for any file extension. I will now go ahead and drown in my sorrow.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Feb 2016 23:00:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-basename-from-path/m-p/203097#M187604</guid>
      <dc:creator>sk314</dc:creator>
      <dc:date>2016-02-12T23:00:25Z</dc:date>
    </item>
    <item>
      <title>Re: extract basename from path</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-basename-from-path/m-p/203098#M187605</link>
      <description>&lt;P&gt;Hi, belowone worked fine. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  | eval filename2=replace(source,"([^\\\]+\\\)","")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However my log file is like&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;D:\Program Files\User\"EXTRACT_VP_IN_SVN_TEST_USER_00459E5E.log
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It prints "EXTRACT_VP_IN_SVN_TEST_USER_00459E5E.log". I need only EXTRACT_VP_IN_SVN_TEST_USER in a field. any ideas are much appreciated&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 08:48:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-basename-from-path/m-p/203098#M187605</guid>
      <dc:creator>deenadp</dc:creator>
      <dc:date>2020-09-29T08:48:19Z</dc:date>
    </item>
    <item>
      <title>Re: extract basename from path</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-basename-from-path/m-p/203099#M187606</link>
      <description>&lt;P&gt;Is there any pattern for your file names that can be used to drop thosse extra characters??&lt;/P&gt;</description>
      <pubDate>Sat, 13 Feb 2016 02:59:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-basename-from-path/m-p/203099#M187606</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-02-13T02:59:45Z</dc:date>
    </item>
    <item>
      <title>Re: extract basename from path</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-basename-from-path/m-p/203100#M187607</link>
      <description>&lt;P&gt;yes, log file always appears after &lt;CODE&gt;"D:\Program Files\User"&lt;/CODE&gt;&lt;BR /&gt;
and File  name always comes after &lt;CODE&gt;"EXTRACT_VP_IN"&lt;/CODE&gt; and before &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"_00459E5E.log"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What I need is only "&lt;STRONG&gt;SVN_TEST_USER&lt;/STRONG&gt;"&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 08:44:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-basename-from-path/m-p/203100#M187607</guid>
      <dc:creator>deenadp</dc:creator>
      <dc:date>2020-09-29T08:44:59Z</dc:date>
    </item>
    <item>
      <title>Re: extract basename from path</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-basename-from-path/m-p/203101#M187608</link>
      <description>&lt;P&gt;Yes, File name always appears after ":D\Program Files\User\" and what I want is only the strings before "_00459E5E.log" from the file name.&lt;/P&gt;

&lt;P&gt;i.e.,  "EXTRACT_VP_IN_SVN_TEST_USER"&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 08:45:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-basename-from-path/m-p/203101#M187608</guid>
      <dc:creator>deenadp</dc:creator>
      <dc:date>2020-09-29T08:45:05Z</dc:date>
    </item>
    <item>
      <title>Re: extract basename from path</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-basename-from-path/m-p/531816#M187609</link>
      <description>&lt;P&gt;For just getting the basename / filename from a file path (e.g. executable file from Windows Security 4688 - new process event) I would just use the Splunk built-in &lt;A title="Search Reference - Multivalue eval functions" href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/MultivalueEvalFunctions" target="_blank" rel="noopener"&gt;Multivalue eval functions&lt;/A&gt; "split" and "mvindex" commands.&amp;nbsp; If regex can be avoided for simplicity, I would suggest that - unless it is the best tool for the job.&lt;/P&gt;&lt;LI-CODE lang="css"&gt;| eval ExeName=mvindex(split(New_Process_Name,"\\"),-1)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Dec 2020 06:07:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-basename-from-path/m-p/531816#M187609</guid>
      <dc:creator>bwlm</dc:creator>
      <dc:date>2020-12-03T06:07:50Z</dc:date>
    </item>
    <item>
      <title>Re: extract basename from path</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-basename-from-path/m-p/566485#M197418</link>
      <description>&lt;P&gt;A very late reply.&amp;nbsp; But this works very well to get the base path:&lt;/P&gt;&lt;P&gt;| makeresults&lt;BR /&gt;| eval path="/opt/splunk/etc/system/local/inputs.conf"&lt;BR /&gt;| eval base_path=replace(path,"\/[^\/]+\.[^\/]+$","")&lt;BR /&gt;| table path base_path&lt;/P&gt;</description>
      <pubDate>Thu, 09 Sep 2021 15:54:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-basename-from-path/m-p/566485#M197418</guid>
      <dc:creator>judevine</dc:creator>
      <dc:date>2021-09-09T15:54:05Z</dc:date>
    </item>
  </channel>
</rss>

