<?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: Btools, the big brother of btool  (tools, not a question) in Splunk Enterprise</title>
    <link>https://community.splunk.com/t5/Splunk-Enterprise/Btools-the-big-brother-of-btool-tools-not-a-question/m-p/740835#M21771</link>
    <description>&lt;P&gt;It's the calling shell that does the file expansion first so disabling globbing inside the function (which runs in a subshell) will not work.&amp;nbsp; &amp;nbsp;Here's an example that hopefully demonstrates this more clearly ...&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;$ mkdir empty
$ mv test.func empty/.test.func
$ cd empty
$ ls      # no files
$ ls -a   # globbing ignores hidden files 
.  ..  .test.func
$ . .test.func
$ test * 2 3   # no files so no globbling and * works 
opt=x**x#x
file=*
stansa=2
search=3
$ touch newfile
$ ls
newfile
$ test * 2 3   
opt=x**x#x
file=newfile
stansa=2
search=3
$ test \* 2 3
opt=x**x#x
file=*
stansa=2
search=3
$ set -f
$ test * 2 3
opt=x**x#x
file=*
stansa=2
search=3
$&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Agree, that using -a switch may be a cleaner way to represent all files though.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 04 Mar 2025 20:23:43 GMT</pubDate>
    <dc:creator>yeahnah</dc:creator>
    <dc:date>2025-03-04T20:23:43Z</dc:date>
    <item>
      <title>Btools, the big brother of btool  (tools, not a question)</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Btools-the-big-brother-of-btool-tools-not-a-question/m-p/740644#M21748</link>
      <description>&lt;P&gt;I have seen many struggle with the btool and the some messy output of it.&lt;/P&gt;&lt;P&gt;So I made an updated version that makes it far better to use.&amp;nbsp; Its made as an function, so you can add it to any start up script on your linux.&lt;/P&gt;&lt;P&gt;It make use of color and sort all settings in groups to make it easy to find your settings.&lt;BR /&gt;In green you see the stanza name. Yellow is each setting for the stanza.&amp;nbsp; And last in grey is the file that holds the setting.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;btools ()
{
# Handle input options
if [[ "$1" == "-sd" || "$1" == "-ds" ]]; then  
  opt="etc/system/default" 
  file="$2"
  stanza=""
  search="$3"
elif [[ "$1" == "-d" &amp;amp;&amp;amp; "$2" == "-s" || "$1" == "-s" &amp;amp;&amp;amp; "$2" == "-d" ]]; then
  opt="etc/system/default" 
  file="$3"
  stanza=""
  search="$4"
elif [[ "$1" == "-d" ]]; then
  opt="etc/system/default"
  file="$2"
  stanza="$3"
  search="$4"
elif [[ "$1" == "-s" ]]; then
  opt="none" 
  file="$2"
  stanza=""
  search="$3"
else  
  opt="none" 
  file="$1"
  stanza="$2"
  search="$3"  
fi

# If no options are given, show the options
[[ -z "$file" ]] &amp;amp;&amp;amp;  echo -e "
 btools for Splunk v3.0 Jotne
 Missing arguments!

 usage: btools [OPTION] file [STANZA] [SEARCH]
 -d    Do not show splunk default
 -s    All stanza (only needed if search is added and no stanza)
 file=splunk config file without the .conf
 [stanza] = complete stanza name or just part of it
 [search] = search phrase or part of it

 Example:
 btools server general servername
 btools web

" &amp;amp;&amp;amp;  return 1

# If options are not set, give default values
[[ -z "$stanza" ]] &amp;amp;&amp;amp; stanza=".*" || stanza=".*$stanza.*"
[[ -z "$search" ]] &amp;amp;&amp;amp; search=""

~/bin/splunk btool $file list --debug |
awk -v reset="\033[m\t" \
 -v yellow="\033[38;5;226m\t" \
 -v green="\033[38;5;46m" ' 									# set the different ansi color used

 {sub(/\s+/,"#");split($0,p,"#")}								# split the input p[1]=filename p[2]=rest of line
 p[2]~/^\[.*?\] *$/ {f=0}										# if this is a stanza name set flag f=0
 f &amp;amp;&amp;amp; tolower(p[2])~tolower(search) {							# if this is not stanza test if text is part of search or no seach 
        split(p[2],s," ")										# Store each stanza in its own group	
        a[st s[1]]++
        if(p[1]!~opt)print green st yellow p[2] reset p[1]		# Print each block
        }
 p[2]~"^\\["stanza"\\]$" {f=1;st=p[2]}							# Find next stans
 ' stanza="$stanza" search="$search" opt="$opt"
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example:&lt;BR /&gt;btools server general servername&lt;BR /&gt;btools web&lt;BR /&gt;&lt;BR /&gt;Lets say you like to see all your custom setting in props.conf for the stansa regarding IP&amp;nbsp;10.36.30.90&lt;BR /&gt;and not show any default settings (-q)&lt;BR /&gt;&lt;STRONG&gt;btools -q props 10.36.30.90&lt;/STRONG&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="btools.png" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/37947i9E80B2719B60EF31/image-size/large?v=v2&amp;amp;px=999" role="button" title="btools.png" alt="btools.png" /&gt;&lt;/span&gt;&amp;nbsp;&lt;BR /&gt;Give me customer setting for index shb_ad&lt;BR /&gt;&lt;STRONG&gt;btools -q indexes shb_ad&lt;/STRONG&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="btools index.png" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/37949iFA47CE9924ECE038/image-size/large?v=v2&amp;amp;px=999" role="button" title="btools index.png" alt="btools index.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Homepath for the shb_ab index:&lt;BR /&gt;&lt;STRONG&gt;btools -q indexes shb_ad homepath&lt;/STRONG&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="btools index homepath.png" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/37950iB852FD942352F07F/image-size/large?v=v2&amp;amp;px=999" role="button" title="btools index homepath.png" alt="btools index homepath.png" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;Give me all settings for index shb_ab (includes the default settings) (ps there are more lines than picture shows.&lt;BR /&gt;&lt;STRONG&gt;btools indexes shb_ad&lt;/STRONG&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="btools index all.png" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/37951i99AB7F753382F6DD/image-size/large?v=v2&amp;amp;px=999" role="button" title="btools index all.png" alt="btools index all.png" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;Any suggestion to make it better is welcome &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Mar 2025 21:37:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Btools-the-big-brother-of-btool-tools-not-a-question/m-p/740644#M21748</guid>
      <dc:creator>jotne</dc:creator>
      <dc:date>2025-03-04T21:37:44Z</dc:date>
    </item>
    <item>
      <title>Re: Btools, the big brother of btool  (tools, not a question)</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Btools-the-big-brother-of-btool-tools-not-a-question/m-p/740672#M21750</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/213488"&gt;@jotne&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;As you may be aware, the * wildcard breaks due to &lt;SPAN&gt;filename expansion (or&amp;nbsp;&lt;/SPAN&gt;globbing) from the calling shell, i.e. what is passed to the btools function is a list of filenames in the directory where the function is called, not the * wildcard.&lt;BR /&gt;&lt;BR /&gt;This can be turned off in the shell with the set -f call (set +f to re-enable), or the more useful convention is to escape the wildcard with a backslash or wrap it in single quotes.&amp;nbsp; Standard *nix commands that use the * wildcard on the command line (e.g. find) use this convention so I think this is a more conventional *nix method than using a ¤. My US keyboard does not provide easy access to this character.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[splunk ~]$ touch test_dummy
[splunk ~]$ btools indexes test* coldpath.maxDataSizeMB
# shell expands to test_dummy so does not work unless the * is escaped
[splunk ~]$ btools indexes test\* coldpath.maxDataSizeMB
[test_cust]     coldPath.maxDataSizeMB = 0      /opt/splunk/etc/system/default/indexes.conf
[splunk ~]$

[splunk@lrlskt02 ~]$ btools indexes * coldpath.maxDataSizeMB
[splunk@lrlskt02 ~]$
[splunk@lrlskt02 ~]$ btools indexes '*' coldpath.maxDataSizeMB
[_audit]        coldPath.maxDataSizeMB = 0      /opt/splunk/etc/system/default/indexes.conf
[_internal]     coldPath.maxDataSizeMB = 0      /opt/splunk/etc/system/default/indexes.conf
[_introspection]        coldPath.maxDataSizeMB = 0      /opt/splunk/etc/system/default/indexes.conf
[_metrics]      coldPath.maxDataSizeMB = 0      /opt/splunk/etc/system/default/indexes.conf
[_metrics_rollup]       coldPath.maxDataSizeMB = 0      /opt/splunk/etc/system/default/indexes.conf
[_telemetry]    coldPath.maxDataSizeMB = 0      /opt/splunk/etc/system/default/indexes.conf
[_thefishbucket]        coldPath.maxDataSizeMB = 0      /opt/splunk/etc/system/default/indexes.conf
[default]       coldPath.maxDataSizeMB = 0      /opt/splunk/etc/system/default/indexes.conf
[history]       coldPath.maxDataSizeMB = 0      /opt/splunk/etc/system/default/indexes.conf
[main]  coldPath.maxDataSizeMB = 0      /opt/splunk/etc/system/default/indexes.conf
[summary]       coldPath.maxDataSizeMB = 0      /opt/splunk/etc/system/default/indexes.conf
[test_cust]     coldPath.maxDataSizeMB = 0      /opt/splunk/etc/system/default/indexes.conf
[splunk@lrlskt02 ~]$&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Mar 2025 03:48:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Btools-the-big-brother-of-btool-tools-not-a-question/m-p/740672#M21750</guid>
      <dc:creator>yeahnah</dc:creator>
      <dc:date>2025-03-04T03:48:51Z</dc:date>
    </item>
    <item>
      <title>Re: Btools, the big brother of btool  (tools, not a question)</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Btools-the-big-brother-of-btool-tools-not-a-question/m-p/740687#M21751</link>
      <description>&lt;P&gt;Thanks for your reply.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried this, but it still expanded a file name. (i did see the problem with expansion so I used a symbol on my key board &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp; )&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;test ()
{
set -f 
if [[ "$1" == "-q" ]]; then
  opt="etc/system/default"
  file="$2"
  stansa="$3"
  search="$4"
else
  opt="x**x#x" 
  file="$1"
  stansa="$2"
  search="$3"
fi


echo "opt=$opt"
echo "file=$file"
echo "stansa=$stansa"
echo "search=$search"
set +f
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;One way I see to solve it is to add another option, like&lt;BR /&gt;-a&amp;nbsp; (all splunk files)&lt;BR /&gt;btools -a &amp;lt;stansa&amp;gt; &amp;lt;search&amp;gt;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Mar 2025 08:30:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Btools-the-big-brother-of-btool-tools-not-a-question/m-p/740687#M21751</guid>
      <dc:creator>jotne</dc:creator>
      <dc:date>2025-03-04T08:30:44Z</dc:date>
    </item>
    <item>
      <title>Re: Btools, the big brother of btool  (tools, not a question)</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Btools-the-big-brother-of-btool-tools-not-a-question/m-p/740835#M21771</link>
      <description>&lt;P&gt;It's the calling shell that does the file expansion first so disabling globbing inside the function (which runs in a subshell) will not work.&amp;nbsp; &amp;nbsp;Here's an example that hopefully demonstrates this more clearly ...&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;$ mkdir empty
$ mv test.func empty/.test.func
$ cd empty
$ ls      # no files
$ ls -a   # globbing ignores hidden files 
.  ..  .test.func
$ . .test.func
$ test * 2 3   # no files so no globbling and * works 
opt=x**x#x
file=*
stansa=2
search=3
$ touch newfile
$ ls
newfile
$ test * 2 3   
opt=x**x#x
file=newfile
stansa=2
search=3
$ test \* 2 3
opt=x**x#x
file=*
stansa=2
search=3
$ set -f
$ test * 2 3
opt=x**x#x
file=*
stansa=2
search=3
$&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Agree, that using -a switch may be a cleaner way to represent all files though.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Mar 2025 20:23:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Btools-the-big-brother-of-btool-tools-not-a-question/m-p/740835#M21771</guid>
      <dc:creator>yeahnah</dc:creator>
      <dc:date>2025-03-04T20:23:43Z</dc:date>
    </item>
    <item>
      <title>Re: Btools, the big brother of btool  (tools, not a question)</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Btools-the-big-brother-of-btool-tools-not-a-question/m-p/740855#M21772</link>
      <description>&lt;P&gt;Thanks for the explanations.&lt;/P&gt;&lt;P&gt;I have made an updated version where there are no need of spesial characters.&lt;BR /&gt;Also cleaned up the code some.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Mar 2025 21:35:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Btools-the-big-brother-of-btool-tools-not-a-question/m-p/740855#M21772</guid>
      <dc:creator>jotne</dc:creator>
      <dc:date>2025-03-04T21:35:23Z</dc:date>
    </item>
  </channel>
</rss>

