<?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: Output only the first n characters of field value in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-output-only-the-first-n-characters-of-field-value/m-p/651930#M225347</link>
    <description>&lt;P&gt;HI&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/258618"&gt;@JohnEGones&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;I have some problem to understand why you're doing this!&lt;/P&gt;&lt;P&gt;Anyway, you can use eval substr to take only the first n chars of a field:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=someIndex sourcetype=someNetworkDevice
| stats count by someField
| eval someField=substr(someField,1,10)&lt;/LI-CODE&gt;&lt;P&gt;as you san see at&amp;nbsp;&lt;A href="https://docs.splunk.com/Documentation/Splunk/9.1.0/SearchReference/TextFunctions#substr.28.26lt.3Bstr.26gt.3B.2C.26lt.3Bstart.26gt.3B.2C.26lt.3Blength.26gt.3B.29" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/9.1.0/SearchReference/TextFunctions#substr.28.26lt.3Bstr.26gt.3B.2C.26lt.3Bstart.26gt.3B.2C.26lt.3Blength.26gt.3B.29&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
    <pubDate>Tue, 25 Jul 2023 15:07:36 GMT</pubDate>
    <dc:creator>gcusello</dc:creator>
    <dc:date>2023-07-25T15:07:36Z</dc:date>
    <item>
      <title>How can I output only the first n characters of field value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-output-only-the-first-n-characters-of-field-value/m-p/651928#M225345</link>
      <description>&lt;P&gt;HI people,&lt;/P&gt;
&lt;P&gt;I want from a query to only print out the first n-characters of the field value. So:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;index=someIndex sourcetype=someNetworkDevice
| stats count by someField&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The output goes:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;someField

this is a strong value 1
this is a string value 1a
this is a string value 2
some other string value 1
some other string value 1a
some other string value 2
this is yet another string value 1
this is yet another string value 1a

etc.&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to pull out say the first 10 characters in each row:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;this is a
this is a
this is a
some other
some other
some other
this is yet
this is yet 

etc&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jul 2023 16:58:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-output-only-the-first-n-characters-of-field-value/m-p/651928#M225345</guid>
      <dc:creator>JohnEGones</dc:creator>
      <dc:date>2023-07-25T16:58:35Z</dc:date>
    </item>
    <item>
      <title>Re: Output only the first n characters of field value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-output-only-the-first-n-characters-of-field-value/m-p/651930#M225347</link>
      <description>&lt;P&gt;HI&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/258618"&gt;@JohnEGones&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;I have some problem to understand why you're doing this!&lt;/P&gt;&lt;P&gt;Anyway, you can use eval substr to take only the first n chars of a field:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=someIndex sourcetype=someNetworkDevice
| stats count by someField
| eval someField=substr(someField,1,10)&lt;/LI-CODE&gt;&lt;P&gt;as you san see at&amp;nbsp;&lt;A href="https://docs.splunk.com/Documentation/Splunk/9.1.0/SearchReference/TextFunctions#substr.28.26lt.3Bstr.26gt.3B.2C.26lt.3Bstart.26gt.3B.2C.26lt.3Blength.26gt.3B.29" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/9.1.0/SearchReference/TextFunctions#substr.28.26lt.3Bstr.26gt.3B.2C.26lt.3Bstart.26gt.3B.2C.26lt.3Blength.26gt.3B.29&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jul 2023 15:07:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-output-only-the-first-n-characters-of-field-value/m-p/651930#M225347</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-07-25T15:07:36Z</dc:date>
    </item>
    <item>
      <title>Re: Output only the first n characters of field value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-output-only-the-first-n-characters-of-field-value/m-p/651931#M225348</link>
      <description>&lt;P&gt;HI Giuseppe,&lt;BR /&gt;&lt;BR /&gt;Nope you got it. Like when it's quick and easy.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jul 2023 15:11:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-output-only-the-first-n-characters-of-field-value/m-p/651931#M225348</guid>
      <dc:creator>JohnEGones</dc:creator>
      <dc:date>2023-07-25T15:11:19Z</dc:date>
    </item>
    <item>
      <title>Re: Output only the first n characters of field value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-output-only-the-first-n-characters-of-field-value/m-p/651932#M225349</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/258618"&gt;@JohnEGones&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;good for you, see next time!&lt;/P&gt;&lt;P&gt;Ciao and happy splunking&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;&lt;P&gt;P.S.: Karma Points are appreciated &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jul 2023 15:12:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-output-only-the-first-n-characters-of-field-value/m-p/651932#M225349</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-07-25T15:12:59Z</dc:date>
    </item>
  </channel>
</rss>

