How to select unique hard link files?


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users How to select unique hard link files?
# 1  
Old 04-17-2013
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.
# 2  
Old 04-17-2013
Example input and outputs please Smilie

Not sure of which size you are talking about!
# 3  
Old 04-17-2013
Code:
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.
# 4  
Old 04-17-2013
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Select Unique Value

HOW CAN I SELECT AN UNIQUE STRING FROM A FIELD? ACTUALLY I WANT TO PRINT RECORDS THAT 2ND FIELD OF THAT HAVE ONE CHARACTER AND IT MUST BE "P" AWK '$2~"" {PRINT $0}' IN > OUTBUT THIS CODE PRINT ALL RECORDS WHICH 2ND FIELDS OF THEM START WITH "P" AND MAY CONTAINS ANOTHER CHARACTER! (1 Reply)
Discussion started by: saeed.soltani
1 Replies

2. Shell Programming and Scripting

select unique

hi, #cat /u01/file|grep -v "^#"|cut -f2 -d: -s i want to avoid repeated lines from the output of the above command. Do we have anyting like unique in shell scripting. thx (4 Replies)
Discussion started by: bang_dba
4 Replies

3. UNIX for Advanced & Expert Users

Hard link multiple files

Is it possible to hard link multiple files at the same time? I tried to use wildcards with no luck. This is what I tried. ln /home/hardlink/* /home/hardlink1 (6 Replies)
Discussion started by: cokedude
6 Replies

4. UNIX for Dummies Questions & Answers

Difference between hard link and soft link

Hi Experts, Please help me out to find out difference between a hard link and a soft link. I am new in unix plz help me with some example commands ( for creating such links). Regards S.Kamakshi :) (2 Replies)
Discussion started by: kamakshi s
2 Replies

5. UNIX for Dummies Questions & Answers

Hard Link vs SOft Link????

Hi PLease let me know the usage of Hard Link vs Soft Link i.e what is the basic difference and what happens when one file is changed or deleted in both the cases??? thanks (3 Replies)
Discussion started by: skyineyes
3 Replies

6. UNIX for Advanced & Expert Users

Hard link

Hello, In unix, the normal user can't create a hardlink for a directory. why..? Is there any difference between creating a hard link for a file and directory? The super user can create a hard link for directories. Why we cannot create and super user can create.? Please, can anyone help... (1 Reply)
Discussion started by: nagalenoj
1 Replies

7. UNIX for Dummies Questions & Answers

need some info about symbolic link and hard link

hello folks how y'all doin well i have some questions about symbolic link and hard link hope some one answer me i open terminal and join as root and i wrote ln -s blah blah then i wrote ls i see red file called blah blah but didn't understand what is this can some one explain and... (2 Replies)
Discussion started by: detective linux
2 Replies

8. UNIX for Dummies Questions & Answers

Difference between hard link and soft link in unix

Hi All, Can any one please explain me what is the difference between hard link and soft link in UNIX. Thanks in advance Raja Chokalingam. (2 Replies)
Discussion started by: RAJACHOKALINGAM
2 Replies

9. UNIX for Dummies Questions & Answers

Why use a hard link

Someone asked me a question today about the difference between a hard link and a soft link. That got me thinking and maybe someone can answer. Why would I ever use a hard link if I can use a soft link instead? (2 Replies)
Discussion started by: dangral
2 Replies

10. UNIX for Advanced & Expert Users

Differences between hard link and soft link

Hi all! I'd like to know the differences between hard links and soft links. I've already read the ln manpage, but i'm not quite sure of what i understood. Does a hard link sort of copy the file to a new name, give it the same inode number and same rights? What exactly should I do to do this:... (3 Replies)
Discussion started by: penguin-friend
3 Replies
Login or Register to Ask a Question