<?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: Replacing &amp;quot;\\&amp;quot; with SEDCMD in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Replacing-quot-quot-with-SEDCMD/m-p/24684#M3928</link>
    <description>&lt;P&gt;you can use other delimiter characters with sed; try using percent ('%') characters like this:&lt;BR /&gt;
&lt;PRE&gt;&lt;BR /&gt;
rex field=_raw mode=sed "s%/%%g"&lt;BR /&gt;
&lt;/PRE&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 30 Apr 2015 19:37:42 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2015-04-30T19:37:42Z</dc:date>
    <item>
      <title>Replacing "\\" with SEDCMD</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Replacing-quot-quot-with-SEDCMD/m-p/24677#M3921</link>
      <description>&lt;P&gt;I have some log data in CEF format that is using "\\" for Windows directory paths, so they look like:  &lt;/P&gt;

&lt;P&gt;c:\\directory\\subdirectory&lt;/P&gt;

&lt;P&gt;I've tried using sed to replace that with a single "\" character, but it's always failing.  I think it's escaping the "/" character in the sed command.  &lt;/P&gt;

&lt;P&gt;How can I replace that either at search time or indexing (preferred)?&lt;/P&gt;

&lt;P&gt;Thx.&lt;/P&gt;

&lt;P&gt;Craig&lt;/P&gt;</description>
      <pubDate>Thu, 02 Aug 2012 21:31:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Replacing-quot-quot-with-SEDCMD/m-p/24677#M3921</guid>
      <dc:creator>responsys_cm</dc:creator>
      <dc:date>2012-08-02T21:31:43Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing "\\" with SEDCMD</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Replacing-quot-quot-with-SEDCMD/m-p/24678#M3922</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;SEDCMD-replace = s/\\\\/\\/g
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;though that may replace if it finds it in other places besides a file path.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Aug 2012 23:02:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Replacing-quot-quot-with-SEDCMD/m-p/24678#M3922</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2012-08-02T23:02:54Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing "\\" with SEDCMD</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Replacing-quot-quot-with-SEDCMD/m-p/24679#M3923</link>
      <description>&lt;P&gt;Nope.  That doesn't work in props.conf or with rex mode=sed.&lt;/P&gt;

&lt;P&gt;Here's the problem...&lt;/P&gt;

&lt;P&gt;rex field=_raw mode=sed "s/\\\\/\\/g" produces:&lt;/P&gt;

&lt;P&gt;Error in 'rex' command: Failed to initialize sed. Failed to parse the regex to replace.&lt;/P&gt;

&lt;P&gt;I get the same result with:&lt;/P&gt;

&lt;P&gt;rex field=_raw mode=sed "s/\\\\/slash/g"&lt;/P&gt;

&lt;P&gt;This successfully replaces the double backslash:&lt;/P&gt;

&lt;P&gt;rex field=_raw mode=sed "s/\\\{2}/slash/g"&lt;/P&gt;

&lt;P&gt;But any replacement text that ends with a backslash throws an error.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Aug 2012 17:24:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Replacing-quot-quot-with-SEDCMD/m-p/24679#M3923</guid>
      <dc:creator>responsys_cm</dc:creator>
      <dc:date>2012-08-03T17:24:34Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing "\\" with SEDCMD</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Replacing-quot-quot-with-SEDCMD/m-p/24680#M3924</link>
      <description>&lt;P&gt;You may want to try:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;SEDCMD-replace = s/(\\\){1}\\\{1}/\1/g
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It might be that the SEDCMD has the same problem as the search time based "rex" command. For doing the replacement at search time, you can definitely use:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex mode=sed "s/(\\\){1}\\\{1}/\1/g"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;or to clean it up...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex mode=sed "s/(\\\){2}/\1/g"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The key seems to be that the \ character needs to be followed by another character other than a forward slash in the replacement group. The regex is working around this by capturing a slash and then we re-use that captured slash as our replacement so we can use characters that are not a backslash in the replacement.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Oct 2012 18:27:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Replacing-quot-quot-with-SEDCMD/m-p/24680#M3924</guid>
      <dc:creator>Rob</dc:creator>
      <dc:date>2012-10-16T18:27:15Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing "\\" with SEDCMD</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Replacing-quot-quot-with-SEDCMD/m-p/24681#M3925</link>
      <description>&lt;P&gt;can u help me to do it in reverse .. to replace single backslash to double backslash in source after the search index=main sourcetype=type|top source | rex ""&lt;BR /&gt;
when i am trying sedcmd , there occurs an error summarizing i dont have permission to use sedcmd. please help&lt;BR /&gt;
thanks for your time&lt;/P&gt;</description>
      <pubDate>Tue, 06 Nov 2012 10:15:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Replacing-quot-quot-with-SEDCMD/m-p/24681#M3925</guid>
      <dc:creator>smolcj</dc:creator>
      <dc:date>2012-11-06T10:15:09Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing "\\" with SEDCMD</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Replacing-quot-quot-with-SEDCMD/m-p/24682#M3926</link>
      <description>&lt;P&gt;&lt;CODE&gt;SEDCMD&lt;/CODE&gt; is a directive in props.conf, not a search command. To emulate this in a search, use &lt;CODE&gt;rex mode=sed &amp;lt;sed_expression&amp;gt;&lt;/CODE&gt; as described in @Rob's answer above.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Nov 2012 16:19:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Replacing-quot-quot-with-SEDCMD/m-p/24682#M3926</guid>
      <dc:creator>sowings</dc:creator>
      <dc:date>2012-11-06T16:19:39Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing "\\" with SEDCMD</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Replacing-quot-quot-with-SEDCMD/m-p/24683#M3927</link>
      <description>&lt;P&gt;thanks sowings, then if i am searching the same like&lt;BR /&gt;
|index=main source= C:\home\filename.txt |rex field=source mode=sed  "s/\/\\/g" &lt;BR /&gt;
i got an error like&lt;BR /&gt;
"Error in 'rex' command: Failed to initialize sed. Failed to parse the regex to replace."&lt;BR /&gt;
i am confused that the reason for this error is my regex. I am trying to replace backslash with double back slash. please help me&lt;BR /&gt;
thanks&lt;/P&gt;</description>
      <pubDate>Wed, 07 Nov 2012 05:13:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Replacing-quot-quot-with-SEDCMD/m-p/24683#M3927</guid>
      <dc:creator>smolcj</dc:creator>
      <dc:date>2012-11-07T05:13:56Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing "\\" with SEDCMD</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Replacing-quot-quot-with-SEDCMD/m-p/24684#M3928</link>
      <description>&lt;P&gt;you can use other delimiter characters with sed; try using percent ('%') characters like this:&lt;BR /&gt;
&lt;PRE&gt;&lt;BR /&gt;
rex field=_raw mode=sed "s%/%%g"&lt;BR /&gt;
&lt;/PRE&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Apr 2015 19:37:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Replacing-quot-quot-with-SEDCMD/m-p/24684#M3928</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-04-30T19:37:42Z</dc:date>
    </item>
  </channel>
</rss>

