How to select unique hard link files?

Calculate the total sze of the files recursively from the current directory. Hard linked files are to be considered only once.

Please use awk also.

Example input and outputs please :slight_smile:

Not sure of which size you are talking about!

find . -type f -ls | awk '{$7+= $7 END {print $7}'

This program will output the size of all the files searched recursively from the current files.
This may also includes the same hard-linked files. So, how to write a program that will fetch the size of all the files but the hard-linked ones have to be included only ones.
I explain the same a bit more. Suppose 2 files are there having same inode number and both are located in the same directory tree from the current directory. So, I need that when the program calculates the total size of all the files, it should consider only 1 file among the 2 hard-linked files.

Do not post classroom or homework problems in the main forums. Homework and coursework questions can only be posted in this forum under special homework rules.

Please review the rules, which you agreed to when you registered, if you have not already done so.

More-than-likely, posting homework in the main forums has resulting in a forum infraction. If you did not post homework, please explain the company you work for and the nature of the problem you are working on.

If you did post homework in the main forums, please review the guidelines for posting homework and repost.

Thank You.

The UNIX and Linux Forums.