I am trying to find all symlinks below current folder whose target contains 'Dropbox'
My best guess was:
find . -type l -iname '*Dropbox*'
But this returns nothing.
I want to find items such as:
com.adobe.illustrator.plist -> /Volumes/data/Dropbox (Personal)/Mackup/Library/Preferences/com.adobe.illustrator.plist
com.apple.Terminal.plist -> /Volumes/data/Dropbox (Personal)/Mackup/Library/Preferences/com.apple.Terminal.plist
com.noodlesoft.Hazel.plist -> /Volumes/data/Dropbox (Personal)/Mackup/Library/Preferences/com.noodlesoft.Hazel.plist
so that I can re-create the links without the (Personal)
text. (If there's a way to do that with one line, that would be excellent!)
Best Answer
If your
find
supports-lname
or-ilname
(GNU extensions also supported by some BSDs (including macOS which your/Volumes
suggest you might be using)).Or case-insensitively:
If not (or even if yes if you want to do anything easily with those links or prefer a sorted list) and you have
zsh
(shipped by default on macOS), you could do:Or to recreate the links:
Note that any shell code can always be written on one line if need be, but I fail to see the point. Here, just join those lines together if you want it on one line.
To do something similar with
bash
and GNU or FreeBSD/macOS utilities, it's more complicated and would be less efficient: