Home
Man
Search
Today's Posts
Register

This forum is closed for new posts. Please post beginner questions to learn unix and learn linux in the UNIX for Beginners Questions & Answers forum.

search for hardlinks based on filename via find command

Tags
$1, $path, -i, account, ai, all files, beginners, command, command substitution, count, dir, directories, directory, display, file, filename, files, find, ha, he i, i-node, inode, inodes, inum, links, list, menu, mib, number, ode, order, path, print, script, search, select, substitution, system, thank you, unix, view, work

 

 
Thread Tools Search this Thread
# 1  
Old 03-25-2001
Error

I am using command substitution into a find command in a script where I have built a menu to do a bunch of tasks within my unix account. When I choose the options for to find a file/files that have the same inode of the entered filename, ie hardlinks, nothing shows up. When I choose the appropiate options to build my find command everything looks to be in order. I need to know how do I get the hard links to print out. Below is the segment of the menu that I use to build the find command for the find path -inum filename -print:

echo "\n Select the number of the search primary"

echo "\n 1) Search based on inodes (-inodes via filename)"

echo "\n Choice: \c"
read pchoice

case $pchoice in
1) srch_pri='-inum';;
esac

case $pchoice in
1) echo "Filename: \c";
read srch_arg;;
esac

echo "Select number of the action primary"

echo "\n 1) Display the current pathname (-print)"

echo "\n Choice: \c"
read achoice

case $achoice in
1) act_pri = '-print';;
esac

case $achoice in
1) act_arg='';;
esac

path =$HOME

find $path $srch_pri $srch_arg $act_pri $act_arg
# 2  
Old 03-25-2001
find &ltdir&gt ! -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]
# 3  
Old 03-27-2001
Thank you for your help mib

Thanks, that helped alot.
 

« Previous Thread | Next Thread »
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to find a file based on pattern & return the filename if found? buster_t UNIX for Dummies Questions & Answers 10 04-07-2014 07:41 AM
Find the latest file based on the date in the filename rudoraj Shell Programming and Scripting 1 09-18-2013 11:07 AM
Find command error having space in filename millan Shell Programming and Scripting 5 06-11-2013 04:46 AM
Only filename from find command parthmittal2007 Shell Programming and Scripting 13 04-02-2012 10:48 AM
Howto get only filename from find command in Linux? nguyendu0102 Shell Programming and Scripting 5 04-12-2011 02:47 AM
how to get only filename in a recursively find command jao_madn Shell Programming and Scripting 2 04-03-2011 10:26 PM
How to find function name based on word search spc432 UNIX for Dummies Questions & Answers 9 07-16-2009 06:05 AM
Find and store files based on FileName and Modified Time edisonantus UNIX for Advanced & Expert Users 2 02-19-2008 02:25 PM
Using find command for timestamp based search sunny_03 UNIX for Dummies Questions & Answers 1 02-12-2008 05:38 AM
find filename based on file content kollerj UNIX for Dummies Questions & Answers 4 06-02-2001 02:31 PM


All times are GMT -4. The time now is 08:35 PM.

Unix & Linux Forums Content Copyright 1993-2018. All Rights Reserved.
UNIX.COM Login
Username:
Password:  
Show Password