How to manually hardlink

How to manually hardlink multiple files to point to one single file. This will drastically help you if you have multiple files that are all the same because instead of editing all of the files you just need to edit one.

This is the command that I ran
#find . -name ‘FiletoFind.txt’ -exec ln -f newfile_hardlink.txt {} \;

FiletoFind.txt is the file name that you want to search for. newFile_hardlink.txt is the file you want all the files to look at after they are found.

I then executed,
#ls -alh newFile_hardlink.txt

This will show you how many files you hardlinked to that one file.

After doing this for a work project I got, -rw-r–r– 4031 dcameron apache 1.3K Dec 15 18:45 newFile_hardlink.txt

Wow, four thousand files that I just saved myself from editing.

About the Author, Dan Cameron:

I'm the owner and solution engineer at Sprout Venture, a web solutions company that specializes in web development including WordPress.

I started my first blog in 2003 and transitioned to WordPress in 2004. Since moving to WordPress I've written a few plugins and themes for public consumption. Lately I'm busy engineering/building/coding and have only been able to share a few code snippets.

If you're in need of some web development, web design or custom WordPress plugins and/or themes contact me, I'll be happy to discuss it with you.

Read More »

  • Oh, yeah. I think you told me about that, actually. I forgot.
  • Dan
    The previous developers made it so when an account was created a new directory would be created with a new index.php file within. So 4K accounts equals 4K directories, 4K index files and 10K more subdirectories; all for nothing. This is one of the main reasons we moved to wpmu.
  • JaredB
    I was wondering the same thing.
  • I'm curious why you have 4K files with identical contents. Pray tell.
blog comments powered by Disqus