今日已更新 166 条资讯 | 累计 20138 条内容
关于我们

find command finds things

Eric Chen 2026年07月16日 02:47 1 次阅读 来源:Dev.to

Recently I learned: find is a useful command to find files in your directories. find folder1 folder2 folder3 This dumps every file and directory under those folders. It also supports flags such as -name "*.txt" to find files matching a particular pattern. There are also filters for size, permissions, and last modified date. I'm thinking this would be a great tool for sanity-testing code that creates nested directories (like a new Docker container's filesystem). This command will give me a full flat listing of the resulting tree (like a deeply nested ls command`). The downside is of course it can dump a lot of output, but in sanity-testing scenarios, there shouldn't be that many files anyways. Something interesting is that this command will take multiple folders before the flags. I'm used to thinking of programs where the arguments are all positionally ordered, so if you don't pass a flag it just assumes the next thing is a regular argument. In this case, find checks whether an argument looks like a flag (starts with - ) before deciding whether to treat it as a path or as part of the expression. I wonder if this is a common pattern across other Linux commands. (Claude says find is special case, but I need to look more into this.)

本文内容来源于互联网,版权归原作者所有
查看原文