LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   how to view only hard links (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-view-only-hard-links-4175534942/)

arun natarajan 02-24-2015 07:20 AM

how to view only hard links
 
Hi All,

Is there any command or shell scripting to view only the link files under / .

pan64 02-24-2015 07:50 AM

what do you mean by that?
when you execute ls -l you will see something like this:
Code:

eporand@elxj3lld12-mf:/tmp/a$ ls -la
total 0
drwxr-xr-x  2 user group 140 Feb 24 14:46 .
drwxrwxrwt 17 root    root      580 Feb 24 14:45 ..
-rw-r--r--  3 user group  0 Feb 24 14:46 asdf
-rw-r--r--  3 user group  0 Feb 24 14:46 asdf1
-rw-r--r--  1 user group  0 Feb 24 14:46 asdf2
-rw-r--r--  3 user group  0 Feb 24 14:46 asdf3
-rw-r--r--  1 user group  0 Feb 24 14:46 asdf4

at the hardlinked files you will see the number of hard links.
also you can check the man page of find (see -links)

TB0ne 02-24-2015 10:11 AM

Quote:

Originally Posted by arun natarajan (Post 5322508)
Hi All,
Is there any command or shell scripting to view only the link files under / .

As suggested, you can read the man page on the find command, and also read the man page on the ls command. BOTH have ample documentation to let you do what you're after. And if you want to write a shell script to do this, that's certainly something that can be done.

suicidaleggroll 02-24-2015 10:25 AM

Every file/dir that's not a sym link is a hard link. So a simple inverse sym link search would return everything that is not a sym link, and is therefore a hard link.

rknichols 02-24-2015 11:59 AM

Quote:

Originally Posted by suicidaleggroll (Post 5322582)
Every file/dir that's not a sym link is a hard link.

And for that matter, every symlink has at least one hard link, i.e., the directory entry that points to the inode that contains the symlink. The only things in the filesystem that do not have a hard link are deleted files that are held open by some process and will be removed as soon as they are closed.


All times are GMT -5. The time now is 12:51 AM.