I'm trying to use a single line command that will find every directory (or sub-directory) named bin
and will then print a list of all the files under it, but will not also list the directory names under them.
I've tried a couple different things to accomplish this, but so far none have worked:
find ~ -type d -name "bin" -exec ls '{}' ';' | grep -v /
I tested this and it will list the files, but it also list directories under whatever bin is there. So if I have a bin
sub-directory under a bin
directory that looks like this:
~/home/
~/home/bin
file1.txt
~/home/bin/bin
file2.txt
The output looks something like this:
bin
file1.txt
file2.txt
find ~ -type d -name "bin" -exec ls -f '{}' ';'
I read that doing ls -f
will list only files, but this unfortunately also lists the directories bin
, ..
and .
So how can I do this?