03-25-2001
find <dir> ! -type d -links +1 -ls|sort -n
this will print all hardlinks in specified directory, sorted by files i-node.
the ! -type d is to avoid directories.
The -links +1 will find all files that have MORE than 1 link. Hardlinked files have a link count of at least two.
The -ls is used to view the inode number after find has found the file.
- The sort -n will sort the list by inode number showing you which files are hardlinked together.
This will only work if your search includes the directories that contain all of the hardlinked files.
here is anotherway
f=`ls -i $srch_arg |awk '{print $1}'`
find / -inum $f
this will search all system and print any files that is hardlinked with $srch_arg
[Edited by mib on 03-25-2001 at 06:05 AM]
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
:confused: There is a flat file on my system which contains email addreses of people in my company. This file is utilized when sending notifications for various things. However nobody knows where this file is located or what it is named. The only thing we know is the email address of a user who... (4 Replies)
Discussion started by: kollerj
4 Replies
2. UNIX for Dummies Questions & Answers
Hi,
I am writing a script where i need to list all the files that have a scecific timestamp. I get this time stamp from another file. Is it possible to do this with 'find' command?
Please let me know your valuable inputs.
Thanks
Sunny. (1 Reply)
Discussion started by: sunny_03
1 Replies
3. UNIX for Advanced & Expert Users
Hi,
I am currently using the following command:
files=(ls enuCPU??.????.exp ntuCPU??.????.exp)
I need to now change the commmand to store the file names of files that have been modified before datetime equal to say '02/16/2008 20:30:00'
What could I use? (2 Replies)
Discussion started by: edisonantus
2 Replies
4. UNIX for Dummies Questions & Answers
Hi All,
I want to find out function name based on word.
Here i ll give u one example
I have several files based on below format. file will start and ends with same name only
EX: file1.txt
public function calculate1()
{
----
----
call Global Function1()
----
----
} END... (9 Replies)
Discussion started by: spc432
9 Replies
5. Shell Programming and Scripting
Hi i would like to ask on how to accomplish the FF:
I want to execute a find command recursively and only get the filename something like i want only the last field set if is used ever the fieldvset as an redirection from the output of the find command
For example:
dir1/dir2/filename1... (2 Replies)
Discussion started by: jao_madn
2 Replies
6. Shell Programming and Scripting
Hi every body!
I would like to get only filename in the result of find command in Linux but I don't know howto. Tks so much for your helps. (5 Replies)
Discussion started by: nguyendu0102
5 Replies
7. Shell Programming and Scripting
Hi All
When we use find command command in Unix we get the result as
/home/user/folder/filename1
/home/user/folder/filename2
/home/user/folder/filename3
Is it possible that i only get the file name
The expected output when using find command is
filename1
filename2
filename3
I am... (13 Replies)
Discussion started by: parthmittal2007
13 Replies
8. Shell Programming and Scripting
Hi,
I am working in solaris.I am using below script to copy the files from /usr/tmp to /usr/gm
But while running this it is not considering the files list after the filename having space in them.
Example:-
compile_custom_pll.sh
conv_data_sqlload.sh
conv_sqlload.sh
Copy of... (5 Replies)
Discussion started by: millan
5 Replies
9. Shell Programming and Scripting
Hi,
We've a list of files that gets created on a weekly basis and it has got a date and time embedded to it. Below are the examples. I want to find out how to get the latest files get the date and time stamp out of it.
Files are
PQR123.PLL.M989898.201308012254.gpg... (1 Reply)
Discussion started by: rudoraj
1 Replies
10. UNIX for Dummies Questions & Answers
Hi all,
I am a newbie here. I have this requirement to find a file based on a pattern then return the filename if found.
I created a script based on online tutorials. Though, I am stuck & really appreciate if anyone can have a quick look & point me to the right direction?
#Script starts... (10 Replies)
Discussion started by: buster_t
10 Replies
LS(1) General Commands Manual LS(1)
NAME
ls - list the contents of a directory
SYNOPSIS
ls [-acdfgilqrstu1ACFLMRTX] [name...]
DESCRIPTION
For each file argument, list it. For each directory argument, list its contents. The current working directory is listed when no files
are named. Information is printed multicolumn on terminals, single column if the output is redirected. The options control what informa-
tion is shown and how.
Ls has two sources other then the commands line to draw options from, one is the environment variable LSOPTS and is used only when the out-
put of ls is displayed on a terminal. The other is the name of ls itself. If ls is linked to another name, then all the characters after
the l are used as flags too, except that f, r, t and x are translated to F, R, T and X. Useful links are ll, lf, lm and lx.
Files whose names start with a dot are by default not listed.
Note that standard Minix doesn't have symbolic links or sockets and -u and -c are no-ops on a V1 file system, since only modified times are
stored in V1 inodes.
OPTIONS
-a All entries are listed, even . and ..
-c Use inode changed time for sorting, listing or searching.
-d Do not list contents of directories, but list the directory itself.
-f Do not sort (should also be: treat a file as a directory, but that can't be implemented portably).
-g Suppress the owner name on a long listing (implies -l).
-i I-node number printed in first column.
-l Long listing: mode, links, owner, group, size and time. (ls -lC uses columns in a wide enough window!)
-n Print numerical user and group id's.
-q Print nongraphic characters as '?' (default on terminals).
-r Reverse the sort order.
-s Give size in kilobytes.
-t Sort by time (modified time default), latest first.
-u Use last accessed time for sorting, listing or searching.
-1 Print in one column.
-A List all entries, but not . and .. (This is the default for privileged users.)
-C Print multicolumn (default on terminals).
-F Mark directories with a '/', executables with a '*', UNIX domain sockets with a '=' and symbolic links with a '@' behind the name.
-L Print the file referenced by a symbolic link instead of the link.
-M List mode before name (implies -C).
-R List directory trees recursively.
-T Group files by type, i.e. regular files together, directories together, etc.
-X Print crunched mode and size before name (implies -C). Only the rwx permissions that its caller has on the file, but they are in
upper case if the caller owns the file and has given the permission to the callers group or other users. The size is listed in
bytes (<= 5K), or rounded up kilo, mega or gigabytes.
SEE ALSO
du(1), stat(1), stat(2).
BUGS
Having to type ls -C when viewing files through more(1).
Is only portable to systems with the same st_mode (see stat(2)).
The LSOPTS variable and the -M, -T and -X flags are not found on other ls implementations. (They have there own nonstandard flags.)
AUTHOR
Kees J. Bot (kjb@cs.vu.nl)
LS(1)