<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>bash &amp;mdash; LinuxPizza</title>
    <link>https://blogs.linux.pizza/tag:bash</link>
    <description>Personal notes and occasional posts - 100% human, 0% AI generated</description>
    <pubDate>Tue, 14 Apr 2026 12:01:13 +0000</pubDate>
    <item>
      <title>Download all files in a remote catalogue over SFTP with lftp</title>
      <link>https://blogs.linux.pizza/download-all-files-in-a-remote-catalogue-over-sftp-with-lftp</link>
      <description>&lt;![CDATA[Hopefully this will save some of you alot of time, energy, and save you day.&#xA;&#xA;I recently had troubles getting a job to work. The short story is:&#xA;&#xA;Download all files in a remote catalogue, over SFTP, on certain times.&#xA;&#xA;I had a working solution with curl, but when the naming of the files changed (such as whitespaces) - the function broke.&#xA;&#xA;lftp - the saver&#xA;&#xA;After have spent a couple of hours trying to grasp lftp via the manpage, I came up with a solution:&#xA;lftp -c &#39;&#xA;open sftp://USER:PASSWORD@remoteserver.example.com:22&#xA;mirror --verbose --use-pget-n=8 -c /remote/catalogue/ /local/catalogue/&#xA;&#39;&#xA;And if you want to remove the source-files after download:&#xA;lftp -c &#39;&#xA;open sftp://USER:PASSWORD@remoteserver.example.com:22&#xA;mirror --Remove-source-files --verbose --use-pget-n=8 -c /remote/catalogue/ /local/catalogue/&#xA;&#39;&#xA;&#xA;This download all files in the specified remote catalogue to the specified local one, then exits.&#xA;&#xA;#linux #bash #sftp #lftp]]&gt;</description>
      <content:encoded><![CDATA[<h3 id="hopefully-this-will-save-some-of-you-alot-of-time-energy-and-save-you-day" id="hopefully-this-will-save-some-of-you-alot-of-time-energy-and-save-you-day">Hopefully this will save some of you alot of time, energy, and save you day.</h3>

<p>I recently had troubles getting a job to work. The short story is:</p>

<p>Download all files in a remote catalogue, over SFTP, on certain times.</p>

<p>I had a working solution with curl, but when the naming of the files changed (such as whitespaces) – the function broke.</p>

<h3 id="lftp-the-saver" id="lftp-the-saver">lftp – the saver</h3>

<p>After have spent a couple of hours trying to grasp lftp via the manpage, I came up with a solution:</p>

<pre><code>lftp -c &#39;
open sftp://USER:PASSWORD@remoteserver.example.com:22
mirror --verbose --use-pget-n=8 -c /remote/catalogue/ /local/catalogue/
&#39;
</code></pre>

<p>And if you want to remove the source-files after download:</p>

<pre><code>lftp -c &#39;
open sftp://USER:PASSWORD@remoteserver.example.com:22
mirror --Remove-source-files --verbose --use-pget-n=8 -c /remote/catalogue/ /local/catalogue/
&#39;
</code></pre>

<p>This download all files in the specified remote catalogue to the specified local one, then exits.</p>

<p><a href="https://blogs.linux.pizza/tag:linux" class="hashtag"><span>#</span><span class="p-category">linux</span></a> <a href="https://blogs.linux.pizza/tag:bash" class="hashtag"><span>#</span><span class="p-category">bash</span></a> <a href="https://blogs.linux.pizza/tag:sftp" class="hashtag"><span>#</span><span class="p-category">sftp</span></a> <a href="https://blogs.linux.pizza/tag:lftp" class="hashtag"><span>#</span><span class="p-category">lftp</span></a></p>
]]></content:encoded>
      <guid>https://blogs.linux.pizza/download-all-files-in-a-remote-catalogue-over-sftp-with-lftp</guid>
      <pubDate>Wed, 11 Jan 2023 08:58:22 +0000</pubDate>
    </item>
  </channel>
</rss>