<?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 use rex to extract Linux directory sizes and names? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-rex-to-extract-Linux-directory-sizes-and-names/m-p/251911#M75317</link>
    <description>&lt;P&gt;Additional question 'to the same scenario':  If we would have the following (&lt;STRONG&gt;within&lt;/STRONG&gt; the same event)&lt;/P&gt;

&lt;P&gt;1000    dir1&lt;BR /&gt;
1200    dir2&lt;BR /&gt;
1550    dir3&lt;BR /&gt;
Etc.&lt;/P&gt;

&lt;HR /&gt;

&lt;PRE&gt;&lt;CODE&gt; .... | rex "(?&amp;lt;size&amp;gt;\d+)\s+(?&amp;lt;dir&amp;gt;\w+)" | eval GB=(size/1024)/1024 | timechart mode(GB) as Size by dir
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will give me &lt;STRONG&gt;only&lt;/STRONG&gt; the first line, which is 1000 and dir1. &lt;STRONG&gt;How&lt;/STRONG&gt; do I extract the sample above so that I have different events for &lt;STRONG&gt;all&lt;/STRONG&gt; (directories and total values)?&lt;/P&gt;</description>
    <pubDate>Mon, 23 May 2016 07:08:07 GMT</pubDate>
    <dc:creator>edwinmae</dc:creator>
    <dc:date>2016-05-23T07:08:07Z</dc:date>
    <item>
      <title>How to use rex to extract Linux directory sizes and names?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-rex-to-extract-Linux-directory-sizes-and-names/m-p/251908#M75314</link>
      <description>&lt;P&gt;I run a daily script on the server, &lt;STRONG&gt;du -sk&lt;/STRONG&gt;, against a certain directory that contains 200 subdirectories and write that to a &lt;STRONG&gt;.txt&lt;/STRONG&gt; file&lt;/P&gt;

&lt;P&gt;Example output (of the .txt file)&lt;/P&gt;

&lt;P&gt;1000  name1   (1000 = size (total) and name1 = subdirectory)&lt;BR /&gt;
1100  name2&lt;BR /&gt;
1200  name3&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;In Splunk this shows in a similar way as above&lt;BR /&gt;
&lt;STRONG&gt;Time&lt;/STRONG&gt;  and &lt;STRONG&gt;Event&lt;/STRONG&gt; (Event data is 1000 name1)  &lt;EM&gt;-- example --&lt;/EM&gt;&lt;/P&gt;

&lt;P&gt;Next line = 1100 name2, etc.  &lt;EM&gt;--- every line looks like a 'separate' event (=line)  in Splunk --&lt;/EM&gt;&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;Now when I try to Extract new fields it throws: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Error in 'rex' command: Encountered the following error while compiling the regex '(?i)^(?P[^\t]+)': Regex: syntax error in subpattern name (missing terminator) 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;HR /&gt;

&lt;P&gt;Target is to show the output in a graph (likely in MB or GB) per 'subdirectory'. I saw a similar case, but I was not able to re-produce the solution that was stated.&lt;/P&gt;

&lt;P&gt;There is very likely a very simple solution for this &lt;STRONG&gt;to separate the e.g. 1000 from the name1&lt;/STRONG&gt;, but I have not succeeded myself -- Yeah I know &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 17 May 2016 10:57:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-rex-to-extract-Linux-directory-sizes-and-names/m-p/251908#M75314</guid>
      <dc:creator>edwinmae</dc:creator>
      <dc:date>2016-05-17T10:57:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to use rex to extract Linux directory sizes and names?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-rex-to-extract-Linux-directory-sizes-and-names/m-p/251909#M75315</link>
      <description>&lt;P&gt;There's no need for the &lt;CODE&gt;(?i)&lt;/CODE&gt; flag since your regex does not contain alphas.  This command will extract the directory size and name.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex "(?&amp;lt;size&amp;gt;\d+)\s+(?&amp;lt;dir&amp;gt;\w+)" | ...
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 17 May 2016 13:34:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-rex-to-extract-Linux-directory-sizes-and-names/m-p/251909#M75315</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2016-05-17T13:34:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to use rex to extract Linux directory sizes and names?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-rex-to-extract-Linux-directory-sizes-and-names/m-p/251910#M75316</link>
      <description>&lt;P&gt;Worked -- Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 19 May 2016 05:09:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-rex-to-extract-Linux-directory-sizes-and-names/m-p/251910#M75316</guid>
      <dc:creator>edwinmae</dc:creator>
      <dc:date>2016-05-19T05:09:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to use rex to extract Linux directory sizes and names?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-rex-to-extract-Linux-directory-sizes-and-names/m-p/251911#M75317</link>
      <description>&lt;P&gt;Additional question 'to the same scenario':  If we would have the following (&lt;STRONG&gt;within&lt;/STRONG&gt; the same event)&lt;/P&gt;

&lt;P&gt;1000    dir1&lt;BR /&gt;
1200    dir2&lt;BR /&gt;
1550    dir3&lt;BR /&gt;
Etc.&lt;/P&gt;

&lt;HR /&gt;

&lt;PRE&gt;&lt;CODE&gt; .... | rex "(?&amp;lt;size&amp;gt;\d+)\s+(?&amp;lt;dir&amp;gt;\w+)" | eval GB=(size/1024)/1024 | timechart mode(GB) as Size by dir
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will give me &lt;STRONG&gt;only&lt;/STRONG&gt; the first line, which is 1000 and dir1. &lt;STRONG&gt;How&lt;/STRONG&gt; do I extract the sample above so that I have different events for &lt;STRONG&gt;all&lt;/STRONG&gt; (directories and total values)?&lt;/P&gt;</description>
      <pubDate>Mon, 23 May 2016 07:08:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-rex-to-extract-Linux-directory-sizes-and-names/m-p/251911#M75317</guid>
      <dc:creator>edwinmae</dc:creator>
      <dc:date>2016-05-23T07:08:07Z</dc:date>
    </item>
  </channel>
</rss>

