I'm trying to do a recursive search in Terminal to find all files that are not folders; this is to confirm that a large directory structure has no content in it. Is there a way to do this?
Starting with another SuperUser post on finding files with a specific extension and reading the man page for "find", I figured out how to use the Terminal to list all files that not named .DS_store
. This is still a long list though. I think it is only directory paths, but it is too many to go through manually. I have been looking for a way to use FIND or grep to exclude folders/paths from the output without luck, but I feel like there must be a way.
So far I've tried this commands. Using prune:
find "$PWD" -name ".ds" -prune -o -name "*.*" | xargs -0 ls -laht -P 1 find "$PWD" -name ".ds" -prune -o | xargs -0 ls -laht -P 1 find "$PWD" -name ".DS_Store" -prune -o | xargs -0 ls -laht -P 1\n find "$PWD" -name ".DS_Store" -prune -o -name "*.*" | xargs -0 ls -laht -P 1\n
Embarrassing to realize the latter gave me my answer.
Using name/iname:
find -name ds find -iname ds find . -iname ds find . -iname "ds" find . -iname ".ds" find . -iname "\.ds" find . -iname "Store" find . -iname ".DS_Store".
All had print
.
Finally I got frustrated with find and went to grep:
find . -print | grep -v ds find . -print | grep -v DS
At this point I thought I was set on excluding .DS_Store
files. I didn't realize that I would be excluding any files w/ "DS" in the name.
I also have read the man page, and have been googling for things like, [recursive search macos exclude all folders terminal]. That's how I found the post I reference above, as well as https://www.crybit.com/exclude-directories/
but they all end up being about excluding specific directories, not directories as a category.
.DS_Store
files (incorrectly it turned out), so really I was only asking how to exclude directories. I thought the commands I tried were not related to that, so I omitted them. This put me in a bind though as far as how to show that I had put in effort, and the best I could come up with at the time was the pages I had read.find "$PWD" -name ".ds" -prune -o -name "*.*" | xargs -0 ls -laht -P 1
find "$PWD" -name ".ds" -prune -o | xargs -0 ls -laht -P 1
find "$PWD" -name ".DS_Store" -prune -o | xargs -0 ls -laht -P 1\n
find "$PWD" -name ".DS_Store" -prune -o -name "*.*" | xargs -0 ls -laht -P 1\n
(embarrassing to realize the latter gave me my answer) Using name/iname:find -name ds
find -iname ds
find . -iname ds
find . -iname "ds"
find . -iname ".ds"
find . -iname "\.ds"
find . -iname "Store"
find . -iname ".DS_Store"
All hadprint