<?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 filename from source in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Extract-filename-from-source/m-p/92730#M19262</link>
    <description>&lt;P&gt;In case if your filename contains a  &lt;CODE&gt;.&lt;/CODE&gt; then&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;# For Unix style
| rex field=&amp;lt;fieldname&amp;gt; "/(?&amp;lt;newField&amp;gt;[\w\d\.]+$)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 21 Aug 2017 10:01:51 GMT</pubDate>
    <dc:creator>koshyk</dc:creator>
    <dc:date>2017-08-21T10:01:51Z</dc:date>
    <item>
      <title>Extract filename from source</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Extract-filename-from-source/m-p/92724#M19256</link>
      <description>&lt;P&gt;I am trying do a search for all exceptions and list the associated filename instead of the whole path+filename in my results table.&lt;/P&gt;

&lt;P&gt;I tried the following in my search but it didn't work:&lt;BR /&gt;
Exception sourcetype=qagadc1 | rex ".&lt;EM&gt;?(?&lt;EXCEPTION&gt;(?:\w+.)+\w&lt;/EXCEPTION&gt;&lt;/EM&gt;?Exception).&lt;EM&gt;" | rex field=source "(?&lt;SOURCE&gt;(/\w&lt;/SOURCE&gt;&lt;/EM&gt;)+)/+(?&lt;FNAME&gt;\w+)+.*" |table source fname&lt;/FNAME&gt;&lt;/P&gt;

&lt;P&gt;my source structure is not unique, they are varies as follow:&lt;BR /&gt;
/home/d1/d2/d3/fn1.log&lt;BR /&gt;
/home/d1/d2/d3/d4/d5/fn2.out&lt;BR /&gt;
/home/d1/d2/d3/d4/d5/d6/fn3.log&lt;BR /&gt;&lt;BR /&gt;
...&lt;/P&gt;

&lt;P&gt;please help.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Apr 2013 21:05:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Extract-filename-from-source/m-p/92724#M19256</guid>
      <dc:creator>vincenty</dc:creator>
      <dc:date>2013-04-12T21:05:40Z</dc:date>
    </item>
    <item>
      <title>Re: Extract filename from source</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Extract-filename-from-source/m-p/92725#M19257</link>
      <description>&lt;P&gt;To extract the last segment of a path from a field you can append this to your search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | eval field = replace(field, ".*/", "")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Edit: If you want the last bit after the final dot you can modify the expression like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  | eval field = replace(field, ".*\.", "")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 12 Apr 2013 21:15:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Extract-filename-from-source/m-p/92725#M19257</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2013-04-12T21:15:38Z</dc:date>
    </item>
    <item>
      <title>Re: Extract filename from source</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Extract-filename-from-source/m-p/92726#M19258</link>
      <description>&lt;P&gt;actually, I am trying to get the filename extension (i.e  fn2.out, fn3.log) as part of the "fname" returned.  &lt;/P&gt;

&lt;P&gt;Tried appending what you suggested still does not give me fn3.log, or fn2.out etc.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Apr 2013 21:48:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Extract-filename-from-source/m-p/92726#M19258</guid>
      <dc:creator>vincenty</dc:creator>
      <dc:date>2013-04-12T21:48:49Z</dc:date>
    </item>
    <item>
      <title>Re: Extract filename from source</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Extract-filename-from-source/m-p/92727#M19259</link>
      <description>&lt;P&gt;actually, I am trying to get the filename extension (i.e  fn2.out, fn3.log) as part of the "fname" returned.  &lt;/P&gt;

&lt;P&gt;Tried appending what you suggested still does not give me fn3.log, or fn2.out etc.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Apr 2013 21:49:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Extract-filename-from-source/m-p/92727#M19259</guid>
      <dc:creator>vincenty</dc:creator>
      <dc:date>2013-04-12T21:49:05Z</dc:date>
    </item>
    <item>
      <title>Re: Extract filename from source</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Extract-filename-from-source/m-p/92728#M19260</link>
      <description>&lt;P&gt;actually, I am trying to get the filename extension (i.e  fn2.out, fn3.log) as part of the "fname" returned.  &lt;/P&gt;

&lt;P&gt;Tried appending what you suggested still does not give me fn3.log, or fn2.out etc.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Apr 2013 21:49:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Extract-filename-from-source/m-p/92728#M19260</guid>
      <dc:creator>vincenty</dc:creator>
      <dc:date>2013-04-12T21:49:31Z</dc:date>
    </item>
    <item>
      <title>Re: Extract filename from source</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Extract-filename-from-source/m-p/92729#M19261</link>
      <description>&lt;P&gt;That's just a matter of modifying the expression, see my edited answer.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Apr 2013 21:51:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Extract-filename-from-source/m-p/92729#M19261</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2013-04-12T21:51:17Z</dc:date>
    </item>
    <item>
      <title>Re: Extract filename from source</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Extract-filename-from-source/m-p/92730#M19262</link>
      <description>&lt;P&gt;In case if your filename contains a  &lt;CODE&gt;.&lt;/CODE&gt; then&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;# For Unix style
| rex field=&amp;lt;fieldname&amp;gt; "/(?&amp;lt;newField&amp;gt;[\w\d\.]+$)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 21 Aug 2017 10:01:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Extract-filename-from-source/m-p/92730#M19262</guid>
      <dc:creator>koshyk</dc:creator>
      <dc:date>2017-08-21T10:01:51Z</dc:date>
    </item>
  </channel>
</rss>

