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

Written by Benjamin Cane on 2011-09-13 20:01:05

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

Picture of Benjamin Cane

Benjamin is a Systems Architect working in the financial services industry focused on platforms that require Continuous Availability. He has been working with Linux and Unix for over 10 years now and has recently published his first book; Red Hat Enterprise Linux Troubleshooting Guide.

Publications

Identify, capture and resolve common issues faced by Red Hat Enterprise Linux administrators using best practices and advanced troubleshooting techniques

What people are saying:
Red Hat Enterprise Linux Troubleshooting Guide may just be all you need in your quest to wear the red hat. - Perry N.
Buy on Amazon

Sponsored by