I need to find files matching the following criteria:
- extension is
md - within folder
.and all subfolders - exclude all
node_modulesfolders - sort by modified date, latest first across all results
I tried this but I guess my exclude for node_modules is wrong as I still get results including node_modules folders when including the fragment \( ! -iname "node_modules" \):
find $PWD -name "*.md" \( ! -iname "node_modules" \) -print0 | xargs -0 ls -laht
-prune. – Kamil Maciorowski Sep 03 '19 at 20:05$PWDshould be double-quoted. (2) When there are many results,xargsmay run two or morelsprocesses in sequence. Eachlswill sort independently, so most likely the overall result will not be sorted as a whole. – Kamil Maciorowski Sep 03 '19 at 20:37-P 1asxargsoption. – Alexander Zeitler Sep 04 '19 at 09:39-P 1in your code will be passed as an option tols, am I wrong? If you move it beforelsthen it will be an option toxargs. Even if it changes anything (1is the default value in GNUxargs, I don't know macOS), it doesn't solve the problem I mentioned. (You may be aware, you used the word "mitigated" instead of "solved"). A way to make a singlels"sort" (semi-)arbitrarily many files is to copy/hardlink/symlink them into a separate directory and invokelsfor the entire directory (with-Lif needed). There may be "maximum number of files per directory" limit though. – Kamil Maciorowski Sep 04 '19 at 10:02