find: Print type of file, inode #, filename and link destination

I have been playing with find a lot lately due to some tasks I have had and someone asked me of a way to duplicate the directory, files, symlinks, and hardlinks of a very large directory on a system that is not connected in any fashion (this eliminates tar or rsync).

The files dont necessarily need to have data and they probably shouldn’t in this case.

Here is the solution I gave him.

Use the find below to create a file that outputs type of file, inode number, filename, link destination if its a symlink. From there he was going to have to script recreating empty files, and creating symlinks/hardlinks to those files.

[[email protected] play]$ find ./ -printf %y %i %p %lrn
d 137042 ./
d 145160 ./somedir
f 135119 ./somefile
l 145231 ./somedir1 somedir
l 149063 ./somedir2 somedir
l 149112 ./somedir3 somedir
f 135119 ./somefile2

About Benjamin

Benjamin is a Infrastructure and Software Engineer. On this blog he writes about Linux, Docker, Programming as well as other Systems topics.

Learn more about Linux

If you liked this article, check out Benjamin's book: Red Hat Enterprise Linux Troubleshooting Guide. Where you can learn a lot more about troubleshooting Linux systems. This book is filled with tips and techniques he has learned over years of managing mission critical systems.