<?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: SEDCMD - special requirement for backslash? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/SEDCMD-special-requirement-for-backslash/m-p/98527#M20598</link>
    <description>&lt;P&gt;I have had many battles with backslashes over the years I've been working with Splunk. Something I thought was working back in the 4.1.3 days seems to not work now. But (and I am on 6.1.5 while writing this) I have found something that works very well, though it is a bit odd looking. Use &lt;CODE&gt;\x5C{1}&lt;/CODE&gt; for the backslash. You can prove to yourself that this works by running the following search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| gentimes start=-1 | eval domainUser="DOMAIN\USERNAME"
| table domainUser
| eval User=domainUser
| rex mode=sed field=User "s/DOMAIN\x5C{1}//"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Here is the output:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;domainUser      User&lt;/CODE&gt;&lt;BR /&gt;
&lt;CODE&gt;DOMAIN\USERNAME    USERNAME&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Ignore the line with the 5. following the rex above. Posting this adds it and I can't get rid of it. Doesn't show when I edit. Pfft.&lt;/P&gt;</description>
    <pubDate>Wed, 13 Jul 2016 22:50:58 GMT</pubDate>
    <dc:creator>wrangler2x</dc:creator>
    <dc:date>2016-07-13T22:50:58Z</dc:date>
    <item>
      <title>SEDCMD - special requirement for backslash?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/SEDCMD-special-requirement-for-backslash/m-p/98515#M20586</link>
      <description>&lt;P&gt;It seems I cannot replace data with a backslash in it.&lt;/P&gt;

&lt;P&gt;For instance: &lt;CODE&gt;DOMAIN\USERNAME&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;I have tried all of the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;SEDCMD-translate=s/DOMAIN\//
SEDCMD-translate=s/DOMAIN\\//
SEDCMD-translate=s/DOMAIN\\\//   ( just for kicks.. nothing else works!)
SEDCMD-translate=s/DOMAIN\\\\//  (works on a unix command line!)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Any suggestions?&lt;/P&gt;</description>
      <pubDate>Mon, 09 May 2011 21:15:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/SEDCMD-special-requirement-for-backslash/m-p/98515#M20586</guid>
      <dc:creator>jgauthier</dc:creator>
      <dc:date>2011-05-09T21:15:28Z</dc:date>
    </item>
    <item>
      <title>Re: SEDCMD - special requirement for backslash?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/SEDCMD-special-requirement-for-backslash/m-p/98516#M20587</link>
      <description>&lt;P&gt;You can try to use another delimiter char for example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;SEDCMD-translate=s#DOMAIN\\##
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Note that you need to escape the \ for the regex to match what you want.&lt;/P&gt;</description>
      <pubDate>Tue, 10 May 2011 01:21:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/SEDCMD-special-requirement-for-backslash/m-p/98516#M20587</guid>
      <dc:creator>Ledion_Bitincka</dc:creator>
      <dc:date>2011-05-10T01:21:21Z</dc:date>
    </item>
    <item>
      <title>Re: SEDCMD - special requirement for backslash?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/SEDCMD-special-requirement-for-backslash/m-p/98517#M20588</link>
      <description>&lt;P&gt;The correct match for a &lt;CODE&gt;\&lt;/CODE&gt; character in this file is &lt;CODE&gt;\\&lt;/CODE&gt;, so your two slashes should work, and it worked for me even with &lt;CODE&gt;/&lt;/CODE&gt; as the SEDCMD delimiter character. Are you sure that the rest of your regex is matching?&lt;/P&gt;</description>
      <pubDate>Tue, 10 May 2011 03:42:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/SEDCMD-special-requirement-for-backslash/m-p/98517#M20588</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2011-05-10T03:42:22Z</dc:date>
    </item>
    <item>
      <title>Re: SEDCMD - special requirement for backslash?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/SEDCMD-special-requirement-for-backslash/m-p/98518#M20589</link>
      <description>&lt;P&gt;I seem to have mixed up the slashes - thus my answer is not really a solution here - I am not deleting just to let people know they can user other delimiters.&lt;/P&gt;</description>
      <pubDate>Tue, 10 May 2011 03:54:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/SEDCMD-special-requirement-for-backslash/m-p/98518#M20589</guid>
      <dc:creator>Ledion_Bitincka</dc:creator>
      <dc:date>2011-05-10T03:54:00Z</dc:date>
    </item>
    <item>
      <title>Re: SEDCMD - special requirement for backslash?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/SEDCMD-special-requirement-for-backslash/m-p/98519#M20590</link>
      <description>&lt;P&gt;Absolutely positive.  If I replace just DOMAIN with something else, that something else shows up in the index.&lt;/P&gt;

&lt;P&gt;As soon as I remove the \, it stops matching.&lt;/P&gt;

&lt;P&gt;I will continue to experiment. Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 10 May 2011 12:45:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/SEDCMD-special-requirement-for-backslash/m-p/98519#M20590</guid>
      <dc:creator>jgauthier</dc:creator>
      <dc:date>2011-05-10T12:45:09Z</dc:date>
    </item>
    <item>
      <title>Re: SEDCMD - special requirement for backslash?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/SEDCMD-special-requirement-for-backslash/m-p/98520#M20591</link>
      <description>&lt;P&gt;Curious.  If I make the sedcmd looks like this:&lt;/P&gt;

&lt;P&gt;SEDCMD-translate=s/DOMAIN\texthere//&lt;/P&gt;

&lt;P&gt;Then "DOMAIN\texthere" is replaced.&lt;/P&gt;

&lt;P&gt;If I leave it as &lt;BR /&gt;
SEDCMD-translate=s/DOMAIN\//&lt;/P&gt;

&lt;P&gt;It doesn't replace "DOMAIN\".&lt;BR /&gt;
I believe it may be a defect.&lt;/P&gt;</description>
      <pubDate>Tue, 10 May 2011 13:42:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/SEDCMD-special-requirement-for-backslash/m-p/98520#M20591</guid>
      <dc:creator>jgauthier</dc:creator>
      <dc:date>2011-05-10T13:42:20Z</dc:date>
    </item>
    <item>
      <title>Re: SEDCMD - special requirement for backslash?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/SEDCMD-special-requirement-for-backslash/m-p/98521#M20592</link>
      <description>&lt;P&gt;Wait, so it sounds to me like it is matching fine? If you remove the &lt;CODE&gt;\&lt;/CODE&gt; and it matches, it should delete the entire match &lt;CODE&gt;DOMAIN\&lt;/CODE&gt;, correct? Or did you mean as soon as you remove the &lt;CODE&gt;\&lt;/CODE&gt; then it &lt;EM&gt;does&lt;/EM&gt; match?&lt;/P&gt;</description>
      <pubDate>Tue, 10 May 2011 13:43:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/SEDCMD-special-requirement-for-backslash/m-p/98521#M20592</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2011-05-10T13:43:35Z</dc:date>
    </item>
    <item>
      <title>Re: SEDCMD - special requirement for backslash?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/SEDCMD-special-requirement-for-backslash/m-p/98522#M20593</link>
      <description>&lt;P&gt;That is not what I typed! BAH.&lt;/P&gt;

&lt;P&gt;Okay, let me try and correct this.&lt;/P&gt;

&lt;P&gt;SEDCMD-translate=s/DOMAIN\texthere//&lt;BR /&gt;
This correctly replaces "DOMAIN\texthere"&lt;/P&gt;

&lt;P&gt;SEDCMD-translate=s/DOMAIN\//&lt;BR /&gt;
This does not correctly replace "DOMAIN\"&lt;/P&gt;

&lt;P&gt;I really botched up that comment with bad backslashes. I'm sorry! I am pretty sure I pasted that correctly.&lt;/P&gt;

&lt;P&gt;In short, if I put text after \ it seems to replace.&lt;BR /&gt;
But ending a replacement with a backslash does not appear to work correctly.&lt;/P&gt;</description>
      <pubDate>Tue, 10 May 2011 15:14:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/SEDCMD-special-requirement-for-backslash/m-p/98522#M20593</guid>
      <dc:creator>jgauthier</dc:creator>
      <dc:date>2011-05-10T15:14:58Z</dc:date>
    </item>
    <item>
      <title>Re: SEDCMD - special requirement for backslash?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/SEDCMD-special-requirement-for-backslash/m-p/98523#M20594</link>
      <description>&lt;P&gt;BAH! It did it again. When I paste my comment it is removing blackslashes. This is going to be a pain to document. Let me double up backslashes and try to get this to take it.&lt;/P&gt;

&lt;P&gt;SEDCMD-translate=s/DOMAIN\\texthere//&lt;/P&gt;

&lt;P&gt;This correctly replaces "DOMAIN\texthere"&lt;/P&gt;

&lt;P&gt;SEDCMD-translate=s/DOMAIN\\//&lt;/P&gt;

&lt;P&gt;This does not correctly replace "DOMAIN\"&lt;/P&gt;</description>
      <pubDate>Tue, 10 May 2011 15:17:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/SEDCMD-special-requirement-for-backslash/m-p/98523#M20594</guid>
      <dc:creator>jgauthier</dc:creator>
      <dc:date>2011-05-10T15:17:58Z</dc:date>
    </item>
    <item>
      <title>Re: SEDCMD - special requirement for backslash?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/SEDCMD-special-requirement-for-backslash/m-p/98524#M20595</link>
      <description>&lt;P&gt;I have the same problem. No number of backslashes works interactively on the search command. Results in the following error "Error in 'rex' command: Failed to initialize sed. Failed to parse the replacement string."&lt;/P&gt;

&lt;P&gt;UPDATE: seems to be fixed in v4.2.3 ... I needed three backslashes \\ for it to work with rex mode=sed field=_raw&lt;/P&gt;</description>
      <pubDate>Fri, 30 Sep 2011 15:18:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/SEDCMD-special-requirement-for-backslash/m-p/98524#M20595</guid>
      <dc:creator>darrellgrundy</dc:creator>
      <dc:date>2011-09-30T15:18:53Z</dc:date>
    </item>
    <item>
      <title>Re: SEDCMD - special requirement for backslash?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/SEDCMD-special-requirement-for-backslash/m-p/98525#M20596</link>
      <description>&lt;P&gt;It works fine using capturing groups. &lt;/P&gt;

&lt;P&gt;In your example, I would use:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;SEDCMD-translate=s/\(DOMAIN\)\\/\1/
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can also try it out raw in the search first by executing:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; your_search | rex mode=sed "s/\(DOMAIN\)\\/\1/"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 17 Apr 2012 19:50:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/SEDCMD-special-requirement-for-backslash/m-p/98525#M20596</guid>
      <dc:creator>ajitsd</dc:creator>
      <dc:date>2012-04-17T19:50:27Z</dc:date>
    </item>
    <item>
      <title>Re: SEDCMD - special requirement for backslash?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/SEDCMD-special-requirement-for-backslash/m-p/98526#M20597</link>
      <description>&lt;P&gt;There is definitely something not quite right when using backslashes with the sed. &lt;/P&gt;

&lt;P&gt;I provided a similar answer here: &lt;A href="http://splunk-base.splunk.com/answers/54904/replacing-with-sedcmd/62199"&gt;http://splunk-base.splunk.com/answers/54904/replacing-with-sedcmd/62199&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Basically, you need to have the backslash characters be followed by a character that is not a slash and definitely not as part of the replacement. ajitsd provided a nice example by using a capture group instead of backslashes. However, you may need to escape more of the backslashes. For one backslash to match you will need to put in three backslashes as darrellgrundy mentioned. Try the following command in a search and see if that works for you:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex mode=sed "s/DOMAIN\\\{1}//g"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 16 Oct 2012 23:59:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/SEDCMD-special-requirement-for-backslash/m-p/98526#M20597</guid>
      <dc:creator>Rob</dc:creator>
      <dc:date>2012-10-16T23:59:39Z</dc:date>
    </item>
    <item>
      <title>Re: SEDCMD - special requirement for backslash?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/SEDCMD-special-requirement-for-backslash/m-p/98527#M20598</link>
      <description>&lt;P&gt;I have had many battles with backslashes over the years I've been working with Splunk. Something I thought was working back in the 4.1.3 days seems to not work now. But (and I am on 6.1.5 while writing this) I have found something that works very well, though it is a bit odd looking. Use &lt;CODE&gt;\x5C{1}&lt;/CODE&gt; for the backslash. You can prove to yourself that this works by running the following search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| gentimes start=-1 | eval domainUser="DOMAIN\USERNAME"
| table domainUser
| eval User=domainUser
| rex mode=sed field=User "s/DOMAIN\x5C{1}//"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Here is the output:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;domainUser      User&lt;/CODE&gt;&lt;BR /&gt;
&lt;CODE&gt;DOMAIN\USERNAME    USERNAME&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Ignore the line with the 5. following the rex above. Posting this adds it and I can't get rid of it. Doesn't show when I edit. Pfft.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jul 2016 22:50:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/SEDCMD-special-requirement-for-backslash/m-p/98527#M20598</guid>
      <dc:creator>wrangler2x</dc:creator>
      <dc:date>2016-07-13T22:50:58Z</dc:date>
    </item>
    <item>
      <title>Re: SEDCMD - special requirement for backslash?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/SEDCMD-special-requirement-for-backslash/m-p/98528#M20599</link>
      <description>&lt;P&gt;Just a quick update to this: I've tested this in both &lt;STRONG&gt;SEDCMD&lt;/STRONG&gt; in &lt;STRONG&gt;props.conf&lt;/STRONG&gt; and in search using &lt;STRONG&gt;rex mode=sed&lt;/STRONG&gt; and this works in both places. I think that SEDCMD is more picky, because I've found other ways of doing this in search with rex that don't work with SEDCMD. This works in both.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jul 2016 16:47:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/SEDCMD-special-requirement-for-backslash/m-p/98528#M20599</guid>
      <dc:creator>wrangler2x</dc:creator>
      <dc:date>2016-07-14T16:47:31Z</dc:date>
    </item>
    <item>
      <title>Re: SEDCMD - special requirement for backslash?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/SEDCMD-special-requirement-for-backslash/m-p/98529#M20600</link>
      <description>&lt;P&gt;Just to keep this thread up to date (because it just ended 4 hours of mental torture!), working in 6.5.2,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=User_name mode=sed "s/(\\\\)/\1\1/g" 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;worked for me to translate {anything &amp;amp; any case}\{anything} into the same with a double backslash.&lt;/P&gt;

&lt;P&gt;Useful when building a multiselect source query listing users from hundreds of different servers.&lt;BR /&gt;
Thanks to all the contributors on here for their efforts &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jul 2017 17:42:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/SEDCMD-special-requirement-for-backslash/m-p/98529#M20600</guid>
      <dc:creator>StorageMatt</dc:creator>
      <dc:date>2017-07-04T17:42:43Z</dc:date>
    </item>
    <item>
      <title>Re: SEDCMD - special requirement for backslash?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/SEDCMD-special-requirement-for-backslash/m-p/98530#M20601</link>
      <description>&lt;P&gt;s/\x5C{1}//g works great for this&lt;/P&gt;

&lt;P&gt;Really!? Yes, indeedy! Let's test it.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval domainUser="theLaTiDahDomain\johndoejr"
| table domainUser
| eval User=domainUser
| rex mode=sed field=User "s/.*\x5C{1}//"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This returns &lt;CODE&gt;johndoejr&lt;/CODE&gt; in the User column.&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;| makeresults&lt;/CODE&gt; is a new feature beginning in 6.3, I believe. If you are on an earlier release use &lt;CODE&gt;| gentimes start=-1&lt;/CODE&gt; instead.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Aug 2017 20:52:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/SEDCMD-special-requirement-for-backslash/m-p/98530#M20601</guid>
      <dc:creator>wrangler2x</dc:creator>
      <dc:date>2017-08-24T20:52:08Z</dc:date>
    </item>
  </channel>
</rss>

