Using find with symbolic links

Josh Sherman
1 min read
Command-line Interface

Symbolic links, or symlinks come in handy when you need to share directories with multiple directories and not have to worry about keeping each linked instance in sync.

The problem with symlinks is that not every command-line utility supports them, and often times, they do support them, but it’s not default behavior.

One such utility is find which allows you to search a directory for files and directories that match a pattern. Out of the box, find doesn’t follow symbolic links.

To will find into following symbolic links, all you need to do is pass in the -L argument (as a predicate to the path):

# Finds all files, but won't follow symlinks
find . -type f

# Finds all files, AND follows symlinks
find -L . -type f

If you happen to want this behavior all of the time, you can simply alias find to include the argument:

alias find='find -L'
Join the Conversation

Good stuff? Want more?

Weekly emails about technology, development, and sometimes sauerkraut.

100% Fresh, Grade A Content, Never Spam.

About Josh

Husband. Father. Pug dad. Musician. Founder of Holiday API, Head of Engineering and Emoji Specialist at Mailshake, and author of the best damn Lorem Ipsum Library for PHP.

Currently Reading

Parasie Eve

Previous Reads

Buy Me a Coffee Become a Sponsor

Related Articles