Register
It is currently Wed Nov 26, 2014 10:13 pm

i-node checking script


All times are UTC - 6 hours


Post new topic Reply to topic  [ 3 posts ] 
Author Message
 PostPosted: Mon Oct 04, 2010 7:49 am   

Joined: Mon Oct 04, 2010 7:42 am
Posts: 1
Hi guys how are you?

I was wondering if someone would be able to whip up a script that takes a directory and outputs the i-node numbers that appear more than once in the directory and its subtrees......Any help would be greatly appreciated


Top
 Profile  
 PostPosted: Mon Oct 04, 2010 1:16 pm   
User avatar

Joined: Sun Jun 27, 2010 12:57 am
Posts: 192
I suggest reading up on the -R and -i options of ls


Top
 Profile  
 PostPosted: Wed Jun 22, 2011 3:26 pm   
User avatar

Joined: Wed Jun 08, 2011 8:27 am
Posts: 189
Location: outer Shpongolia
Code:
#!/bin/bash
shopt -s globstar

for f in "${1:-.}"/**/*; do
    if [[ -e "$f" ]]; then
        inodes+=("$(stat -c %i "$f")")
    fi 
done

printf '%s\n' "${inodes[@]}" | sort | uniq -d


If you don't provide a directory name to the script, it'll do the job in the current one.


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP