The Unix command \texttt{find} is among the first commands taught to beginners, yet remains indispensable for experienced engineers. In this paper, we demonstrate that \texttt{find} possesses unexpected computational power, establishing three Turing completeness results using the GNU implementation (a standard in Linux distributions). (1) \texttt{find} + \texttt{mkdir} (a system that has only \texttt{find} and \texttt{mkdir}) is Turing complete: by encoding computational states as directory paths and using regex back-references to copy substrings, we simulate 2-tag systems. (2) GNU \texttt{find} 4.9.0+ alone is Turing complete: by reading and writing to files during traversal, we simulate a two-counter machine without \texttt{mkdir}. (3) \texttt{find} + \texttt{mkdir} without regex back-references is still Turing complete: by a trick of encoding regex patterns directly into directory names, we achieve the same power. These results place \texttt{find} among the ``surprisingly Turing-complete'' systems, highlighting the hidden complexity within seemingly simple standard utilities.
翻译:Unix 命令 \texttt{find} 是初学者最先学习的命令之一,但对经验丰富的工程师而言仍不可或缺。本文中,我们证明了 \texttt{find} 具有意想不到的计算能力,并利用 GNU 实现(Linux 发行版中的标准版本)建立了三个图灵完备性结果。(1)\texttt{find} + \texttt{mkdir}(一个仅包含 \texttt{find} 和 \texttt{mkdir} 的系统)是图灵完备的:通过将计算状态编码为目录路径,并利用正则表达式反向引用来复制子字符串,我们模拟了 2-标记系统。(2)单独的 GNU \texttt{find} 4.9.0+ 是图灵完备的:通过在遍历过程中读写文件,我们模拟了一个无需 \texttt{mkdir} 的双计数器机。(3)不带正则表达式反向引用的 \texttt{find} + \texttt{mkdir} 仍然是图灵完备的:通过将正则表达式模式直接编码到目录名的技巧,我们实现了相同的计算能力。这些结果将 \texttt{find} 置于“令人惊讶的图灵完备”系统之列,突显了看似简单的标准工具中隐藏的复杂性。