find & symlinks

I just ran into this problem, and it almost became a disaster but I luckily noticed the missing files in time, and I figured I should blog it so that nobody else repeats this mistake.

Did you know that the default behavior of 'find' is to not follow symlinks? Well I sure didn't. Yesterday I was tarring up a whole slew of files, some of which were in symlinked directories. Those ones were ignored. I ended up with about 2/3 of the number I expected, but for some reason I ignored my gut and continued on (never ignore your gut, especially if it's hungry!). By some saving grace I noticed the missing files just a few minutes ago and recovered.

So, the option is '-L' to follow symlinks. Remember that. 'find -L'. Perhaps a bash alias is in order...


1 Comment

I'm glad -L isn't the default...

... because several previous developers/admins have set up recursive symlinks (sometimes necessary). Try doing a find in that directory. OR tarring it up while following symlinks. Not fun.

Several other programs (e.g. grep) do follow those symlinks be default, and it's always a moment of frustration when I realize why my grep -lr is taking forever...

Subscribe to Comments for "find & symlinks" Subscribe to - All comments