<?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 replace one backslash by double backslash in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/replace-one-backslash-by-double-backslash/m-p/102798#M26556</link>
    <description>&lt;P&gt;Hello!&lt;BR /&gt;
I need to provide search only in earliest source in my sourcetype. &lt;BR /&gt;
I use this search request for this purposes:&lt;BR /&gt;
    sourcetype="mysourcetype" | stats earliest(source) as firstsource | search source=firstsource&lt;BR /&gt;
But I get error "No results found". &lt;BR /&gt;
I found that the firstsource of returns in the form of &lt;CODE&gt;D:\MyFolder\Mysourcename.gz&lt;/CODE&gt; while for a successful search must have a value as &lt;CODE&gt;D:\\MyFolder\\Mysourcename.gz&lt;/CODE&gt; &lt;BR /&gt;
How can I replace &lt;CODE&gt;\&lt;/CODE&gt; to &lt;CODE&gt;\\&lt;/CODE&gt;?&lt;/P&gt;</description>
    <pubDate>Mon, 22 Apr 2013 09:01:49 GMT</pubDate>
    <dc:creator>ryastrebov</dc:creator>
    <dc:date>2013-04-22T09:01:49Z</dc:date>
    <item>
      <title>replace one backslash by double backslash</title>
      <link>https://community.splunk.com/t5/Splunk-Search/replace-one-backslash-by-double-backslash/m-p/102798#M26556</link>
      <description>&lt;P&gt;Hello!&lt;BR /&gt;
I need to provide search only in earliest source in my sourcetype. &lt;BR /&gt;
I use this search request for this purposes:&lt;BR /&gt;
    sourcetype="mysourcetype" | stats earliest(source) as firstsource | search source=firstsource&lt;BR /&gt;
But I get error "No results found". &lt;BR /&gt;
I found that the firstsource of returns in the form of &lt;CODE&gt;D:\MyFolder\Mysourcename.gz&lt;/CODE&gt; while for a successful search must have a value as &lt;CODE&gt;D:\\MyFolder\\Mysourcename.gz&lt;/CODE&gt; &lt;BR /&gt;
How can I replace &lt;CODE&gt;\&lt;/CODE&gt; to &lt;CODE&gt;\\&lt;/CODE&gt;?&lt;/P&gt;</description>
      <pubDate>Mon, 22 Apr 2013 09:01:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/replace-one-backslash-by-double-backslash/m-p/102798#M26556</guid>
      <dc:creator>ryastrebov</dc:creator>
      <dc:date>2013-04-22T09:01:49Z</dc:date>
    </item>
    <item>
      <title>Re: replace one backslash by double backslash</title>
      <link>https://community.splunk.com/t5/Splunk-Search/replace-one-backslash-by-double-backslash/m-p/102799#M26557</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;sourcetype="mysourcetype" | stats earliest(source) as firstsource | rex field=firstsource mode=sed "s/\\/\\\\/g" | search source=firstsource
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I think this will work. Note that you'll probably need to escape the backslashes within the rex statement, like above.&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;UPDATE:&lt;/P&gt;

&lt;P&gt;There seems to some issues with backslashes and sed, apparently. Perhaps this can give some guidance.&lt;/P&gt;

&lt;P&gt;&lt;A href="http://splunk-base.splunk.com/answers/24026/sedcmd-special-requirement-for-backslash"&gt;http://splunk-base.splunk.com/answers/24026/sedcmd-special-requirement-for-backslash&lt;/A&gt; &lt;/P&gt;

&lt;P&gt;/K&lt;/P&gt;</description>
      <pubDate>Mon, 22 Apr 2013 09:10:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/replace-one-backslash-by-double-backslash/m-p/102799#M26557</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2013-04-22T09:10:37Z</dc:date>
    </item>
    <item>
      <title>Re: replace one backslash by double backslash</title>
      <link>https://community.splunk.com/t5/Splunk-Search/replace-one-backslash-by-double-backslash/m-p/102800#M26558</link>
      <description>&lt;P&gt;I get error "Error in 'rex' command: Failed to initialize sed. Failed to parse the regex to replace."&lt;/P&gt;</description>
      <pubDate>Mon, 22 Apr 2013 09:37:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/replace-one-backslash-by-double-backslash/m-p/102800#M26558</guid>
      <dc:creator>ryastrebov</dc:creator>
      <dc:date>2013-04-22T09:37:48Z</dc:date>
    </item>
    <item>
      <title>Re: replace one backslash by double backslash</title>
      <link>https://community.splunk.com/t5/Splunk-Search/replace-one-backslash-by-double-backslash/m-p/102801#M26559</link>
      <description>&lt;P&gt;There's something wacky about how the Splunk regex parser interprets backslashes. As a rule of thumb, to match a literal backslash you need one more than you think you do. This should work:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;rex mode=sed field=foo "s/(\\\)/\1\1/g"&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jun 2017 16:50:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/replace-one-backslash-by-double-backslash/m-p/102801#M26559</guid>
      <dc:creator>cphair</dc:creator>
      <dc:date>2017-06-14T16:50:46Z</dc:date>
    </item>
    <item>
      <title>Re: replace one backslash by double backslash</title>
      <link>https://community.splunk.com/t5/Splunk-Search/replace-one-backslash-by-double-backslash/m-p/102802#M26560</link>
      <description>&lt;P&gt;Hello, I tried adding this in CLI search job script using curl and getting no result, any idea? Thanks &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Mar 2019 15:32:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/replace-one-backslash-by-double-backslash/m-p/102802#M26560</guid>
      <dc:creator>splunkreal</dc:creator>
      <dc:date>2019-03-22T15:32:03Z</dc:date>
    </item>
    <item>
      <title>Re: replace one backslash by double backslash</title>
      <link>https://community.splunk.com/t5/Splunk-Search/replace-one-backslash-by-double-backslash/m-p/102803#M26561</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;SOLVED : needed to escape again : "s/(\\\\\)/\1\1/g"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 25 Mar 2019 10:03:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/replace-one-backslash-by-double-backslash/m-p/102803#M26561</guid>
      <dc:creator>splunkreal</dc:creator>
      <dc:date>2019-03-25T10:03:01Z</dc:date>
    </item>
    <item>
      <title>Re: replace one backslash by double backslash</title>
      <link>https://community.splunk.com/t5/Splunk-Search/replace-one-backslash-by-double-backslash/m-p/510505#M142880</link>
      <description>&lt;P&gt;eval new_path = replace( old_path ,"(\\\\)","\\\\\1")&lt;/P&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jul 2020 18:00:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/replace-one-backslash-by-double-backslash/m-p/510505#M142880</guid>
      <dc:creator>manan_amin</dc:creator>
      <dc:date>2020-07-22T18:00:22Z</dc:date>
    </item>
  </channel>
</rss>

