<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recursive on Michael’s Domain</title><link>https://jeltsch.org/en/tags/recursive/</link><description>Recent content in Recursive on Michael’s Domain</description><generator>Hugo</generator><language>en-us</language><copyright>Copyright © 2002 - 2026 Michael Jeltsch.</copyright><lastBuildDate>Fri, 24 Jul 2026 00:18:18 +0300</lastBuildDate><atom:link href="https://jeltsch.org/en/tags/recursive/index.xml" rel="self" type="application/rss+xml"/><item><title>Copying with rsync</title><link>https://jeltsch.org/en/copy_with_rsync/</link><pubDate>Mon, 17 Feb 2020 00:00:00 +0000</pubDate><guid>https://jeltsch.org/en/copy_with_rsync/</guid><description>&lt;p&gt;Reasons why you should (not always, but often) prefer rsync over cp:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Resume Interrupted Transfers
If you are copying a large file and your terminal session crashes or the power cuts out, cp will simply fail, and you have to start over. rsync can pick up right where it left off, which is a massive time-saver for large datasets.&lt;/li&gt;
&lt;li&gt;Efficiency (Delta-Transfer Algorithm)
rsync is designed to be smart. If you are copying a file that already exists at the destination (e.g., you are updating a backup), rsync only copies the parts of the file that have actually changed (the &amp;ldquo;delta&amp;rdquo;) rather than overwriting the entire file. cp, by contrast, always copies the whole file every single time.&lt;/li&gt;
&lt;li&gt;Real-time Progress Monitoring
rsync provides excellent visual feedback. By using the -P (or &amp;ndash;progress) flag, you get a real-time progress bar showing the percentage complete, transfer speed, and estimated time remaining. cp is famously silent, leaving you guessing whether the process is still running or has hung, requiring you to check at the destination via the size of the arriving file, whether anything is progressing (ls -lh filename, or du -hs filename)&lt;/li&gt;
&lt;li&gt;Seamless Remote Transfers
rsync is natively built to work over SSH. You can use it to copy files directly to or from a remote server as easily as copying files on your local machine. cp cannot do this; to use cp for a remote server, you would first need to mount the remote filesystem locally, which is far more complex and prone to errors.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Here is a common use case, the transfer of a directory, including all of its content:&lt;/p&gt;</description></item><item><title>Linux copy (cp)</title><link>https://jeltsch.org/en/linux_copy_cp/</link><pubDate>Wed, 17 Apr 2019 00:00:00 +0000</pubDate><guid>https://jeltsch.org/en/linux_copy_cp/</guid><description>&lt;p&gt;In order to copy all xml files from one directory to another without overwriting existing files with the same name:&lt;code&gt;cp -vnpr /source/*.xml /destination&lt;/code&gt;&lt;/p&gt;</description></item><item><title>File permissions on html server (recursive chmod) differentiating between files and directories</title><link>https://jeltsch.org/en/file_permissions_on_html_server_recursive_chmod_differentiating_between_files_and_directories/</link><pubDate>Sun, 12 Apr 2009 00:00:00 +0000</pubDate><guid>https://jeltsch.org/en/file_permissions_on_html_server_recursive_chmod_differentiating_between_files_and_directories/</guid><description>&lt;p&gt;I recursively screwed up the file permissions in my html servers root directory. To fix it I needed to deploy some &amp;ldquo;advanced&amp;rdquo; chmod settings. Obviously I want to treat directories and files differently. I didn&amp;rsquo;t come up with a better solution than the following:&lt;code&gt;chmod -R u=rw-x,g=rw-x,o=r-wx *chmod -R a+X *&lt;/code&gt;&lt;/p&gt;</description></item><item><title>Recursive grep</title><link>https://jeltsch.org/en/recursive_grep/</link><pubDate>Thu, 05 Apr 2007 00:00:00 +0000</pubDate><guid>https://jeltsch.org/en/recursive_grep/</guid><description>&lt;p&gt;grep (case-insensitive, recursive) grep doesn&amp;rsquo;t offer any possibility to recursively descent down the directory tree. The following command searches e.g. just thru all the files in the current directory:&lt;code&gt;grep bacteria *&lt;/code&gt;To make the search case-insensitive, one can use the i flag:&lt;code&gt;grep -i bacteria *&lt;/code&gt;But if you want to do a recursive search you have to use a quite complicated construction of UNIX commands to achieve this goal:&lt;code&gt;find ~/Mail -type f -exec grep 'bacteria' {} \; -print&lt;/code&gt;This command searches recursively thru the Mail directory of the current user and prints all the lines that contain the word bacteria.&lt;/p&gt;</description></item><item><title>Find and replace with perl</title><link>https://jeltsch.org/en/find_and_replace_with_perl/</link><pubDate>Sun, 28 Jan 2007 00:00:00 +0000</pubDate><guid>https://jeltsch.org/en/find_and_replace_with_perl/</guid><description>&lt;p&gt;To replace the string jeltsch.blogspot.com by the string mnm.no-ip.com/blog you can use perl:&lt;code&gt;perl -pi.bak -e 's|jeltsch.blogspot.com|mnm.no-ip.com\/blog|g' *.html&lt;/code&gt; If you want to do a recursive replacement on a directory tree you can try:&lt;code&gt;perl -pi.bak -e 's|jeltsch.blogspot.com|mnm.no-ip.com\/blog|g' &lt;/code&gt;find jeltsch.org -name &amp;lsquo;*.html&amp;rsquo;``&lt;/p&gt;</description></item></channel></rss>