user134513: I have tried with the commands below
sendtoaddress <address> `bitcoin-cli getbalance` "" "" true
sendtoaddress <address> "bitcoin-cli getbalance" "" "" true
sendtoaddress <address> bitcoin-cli getbalance "" "" true
sendtoaddress <address> getbalance "" "" true
sendtoaddress <address> *.* "" "" true

But none worked
error: Error parsing JSON:


user5406: It sounds like you want to send all wallet funds in a single-line command.
In a Unix shell, this should work:
bitcoin-cli sendtoaddress <address> $(bitcoin-cli getbalance) "" "" true

The Windows command prompt doesn't support the substitution via backticks or $(…), but I'm reading that you should be able to use a FOR /F loop with the usebackq option to emulate it:
for /F "usebackq delims=" %A in (`bitcoin-cli getbalance`) do bitcoin-cli sendtoaddress <address> %A "" "" true

I have no Windows machine and have not tested this, I suggest you verify carefully and use at own risk.
Starting with the next release, Bitcoin Core v24, you will be able to use sendall:
bitcoin-cli sendall '["<address>"]' null "unset" <feerate (s/vB)>


134513: <p>I have tried with the commands below</p>
<pre><code>sendtoaddress &lt;address&gt; `bitcoin-cli getbalance` &quot;&quot; &quot;&quot; true
sendtoaddress &lt;address&gt; &quot;bitcoin-cli getbalance&quot; &quot;&quot; &quot;&quot; true
sendtoaddress &lt;address&gt; bitcoin-cli getbalance &quot;&quot; &quot;&quot; true
sendtoaddress &lt;address&gt; getbalance &quot;&quot; &quot;&quot; true
sendtoaddress &lt;address&gt; *.* &quot;&quot; &quot;&quot; true
</code></pre>
<p>But none worked</p>
<pre><code>error: Error parsing JSON:
</code></pre>
 5406: <p>It sounds like you want to send all wallet funds in a single-line command.</p>
<p>In a <strong>Unix shell</strong>, this should work:</p>
<pre><code>bitcoin-cli sendtoaddress &lt;address&gt; $(bitcoin-cli getbalance) &quot;&quot; &quot;&quot; true
</code></pre>
<p>The <strong>Windows command prompt</strong> doesn't support the substitution via backticks or $(…), but I'm <a href="https://stackoverflow.com/a/43226480/1364089">reading</a> that you should be able to use a <a href="https://ss64.com/nt/for_cmd.html" rel="nofollow noreferrer"><code>FOR /F</code></a> loop with the <code>usebackq</code> option to emulate it:</p>
<pre><code>for /F &quot;usebackq delims=&quot; %A in (`bitcoin-cli getbalance`) do bitcoin-cli sendtoaddress &lt;address&gt; %A &quot;&quot; &quot;&quot; true
</code></pre>
<p>I have no Windows machine and have <em>not tested</em> this, I suggest you verify carefully and use at own risk.</p>
<p>Starting with the next release, <strong>Bitcoin Core v24</strong>, you will be able to use <code>sendall</code>:</p>
<pre><code>bitcoin-cli sendall '[&quot;&lt;address&gt;&quot;]' null &quot;unset&quot; &lt;feerate (s/vB)&gt;
</code></pre>
