How to find all the aliases within a given file system?
I would like to avoid any future problems with aliases (empty files created with the Finder, not to be confused with symbolic links) I might have used in the past and which may stay within the system. I discovered a lot of problem with this type of file:
- to backup (with
rsync
) - to migrate on another file system (with
cp
orrsync
) - to migrate on another system (with
rcp
,scp
orrsync
)…
Now I want either to get rid of all of them or at least to know the size of the risk I still have with the remaining ones.
How may I find all the alias type files within a given filesystem using command line (shell script) using for example:
mdfind
find
Solution 1:
To find aliases with mdfind
, in a Terminal:
mdfind kMDItemKind="Alias"
This will print a list of aliases with the fully qualified pathname.
Note: These are aliases created in Finder, not symbolic links created with the ln
command from a Terminal or script.
To use find
to find symbolic links created by, as an example, ln
have a look at: man find
Example: find / -type l
This will start in the root of the Macintosh HD and traverse the entire filesystem that you have permission to read and output all symbolic links created by, as an example, ln
showing the fully qualified pathname.
To augment the basic command example read man find
.