<?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: How to grep or awk in splunk? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-grep-or-awk-in-splunk/m-p/187641#M54061</link>
    <description>&lt;P&gt;With your query you can try:&lt;/P&gt;

&lt;P&gt;index="some index" | dedup source | sort -source |   eval source1=substr(source,-18 ) | eval source=substr(source1,0,14 ) |dedup sourcetype | table sourcetype, source&lt;/P&gt;</description>
    <pubDate>Wed, 01 Jul 2015 07:34:30 GMT</pubDate>
    <dc:creator>ektasiwani</dc:creator>
    <dc:date>2015-07-01T07:34:30Z</dc:date>
    <item>
      <title>How to grep or awk in splunk?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-grep-or-awk-in-splunk/m-p/187639#M54059</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I am using this query in splunk search -&lt;BR /&gt;
    index="some_index" | dedup source | sort -source | dedup sourcetype | table sourcetype, source&lt;/P&gt;

&lt;P&gt;My result shows like this -&lt;BR /&gt;
sourcetype             | source&lt;BR /&gt;
--------------------- | ---------------------------------------------------------------&lt;BR /&gt;
dev_architecture_dev1 | /u01/splunk/etc/apps/dev-data/data/dev1/dev1-20150629133045.log&lt;BR /&gt;
dev_architecture_dev2  | /u01/splunk/etc/apps/dev-data/data/dev2/dev2-20150626124438.log&lt;/P&gt;

&lt;P&gt;I want to grab only the year, month, day, hour, min and sec right before ".log". e.g. 20150629133045.&lt;BR /&gt;
And then display it like 2015-06-29 13:30:45 in the 'source' column.&lt;/P&gt;

&lt;P&gt;Is there a way to do it in Splunk6?&lt;/P&gt;

&lt;P&gt;Thanks for looking at the question. Hoping to get some answers.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 20:26:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-grep-or-awk-in-splunk/m-p/187639#M54059</guid>
      <dc:creator>nilotpaldutta</dc:creator>
      <dc:date>2020-09-28T20:26:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to grep or awk in splunk?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-grep-or-awk-in-splunk/m-p/187640#M54060</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;You can use this:&lt;BR /&gt;
......|eval source1=substr(source,-18 ) | eval source=substr(source1,0,14 ) | ......&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jul 2015 07:30:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-grep-or-awk-in-splunk/m-p/187640#M54060</guid>
      <dc:creator>ektasiwani</dc:creator>
      <dc:date>2015-07-01T07:30:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to grep or awk in splunk?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-grep-or-awk-in-splunk/m-p/187641#M54061</link>
      <description>&lt;P&gt;With your query you can try:&lt;/P&gt;

&lt;P&gt;index="some index" | dedup source | sort -source |   eval source1=substr(source,-18 ) | eval source=substr(source1,0,14 ) |dedup sourcetype | table sourcetype, source&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jul 2015 07:34:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-grep-or-awk-in-splunk/m-p/187641#M54061</guid>
      <dc:creator>ektasiwani</dc:creator>
      <dc:date>2015-07-01T07:34:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to grep or awk in splunk?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-grep-or-awk-in-splunk/m-p/187642#M54062</link>
      <description>&lt;P&gt;Thanks..!! this solution works. &lt;BR /&gt;
However, is there any other way other than substring? Basically want to make the grab dynamic, so if the position changes in another environment, the query would still work.&lt;BR /&gt;
I have done it in bash using both awk and sed. But seems like splunk syntax are very different.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jul 2015 08:08:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-grep-or-awk-in-splunk/m-p/187642#M54062</guid>
      <dc:creator>nilotpaldutta</dc:creator>
      <dc:date>2015-07-01T08:08:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to grep or awk in splunk?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-grep-or-awk-in-splunk/m-p/187643#M54063</link>
      <description>&lt;P&gt;Yes you can do it using rex also.&lt;/P&gt;

&lt;P&gt;index="Some index" | dedup source | sort - source | rex field=source "-(?&amp;lt;source&amp;gt;&amp;amp;bsol;d+)" | dedup sourcetype | table sourcetype, source&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jul 2015 10:33:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-grep-or-awk-in-splunk/m-p/187643#M54063</guid>
      <dc:creator>ektasiwani</dc:creator>
      <dc:date>2015-07-01T10:33:15Z</dc:date>
    </item>
  </channel>
</rss>

