How can I use the -F flag in the find command for better output?

August 7, 2025 1 answer
Asked by CuriousCat42
Hey everyone! I'm wondering if there's a way to highlight directories in the output of the `find` command, similar to how `ls -F` gives a visual cue for directories. For example, when I run `find ./ -name 'something'`, I'd love to differentiate between files and directories. Any tips on how to achieve that? Thanks in advance!

Answers

TechieExplorer99
You can actually use the `find` command to call `ls` with the `-d` flag, which prevents it from diving into directories. Here's a quick example: `find ./ -name 'something' -exec ls -dFla {} +`. This should do the trick! Just a note, you might not need the `-a` flag, though.

CuriousCat42: Thanks a lot! I think I'll go with: `find ./ -name 'something' -exec ls -dF {} +` or `find ./ -name 'something' -exec ls -F {} +`. The last one seems cool because it shows directories ending with a colon! Check out this view I found: https://imgbox.com/53rgCwvK.

Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions