India Broadband Forum


file files by inode number

This is a discussion on file files by inode number within the Linux forums, part of the Operating Systems category; Every file has an unique inode number, using that we can identify that file. Create two files with similar name. ...

Go Back   India Broadband Forum > Computers > Operating Systems > Linux

India Broadband Forum


                      

Reply

 

LinkBack Thread Tools Display Modes
Old 07-17-09, 12:29 PM   #1
Junior Member
 
Join Date: Jul 2009
Posts: 16
Rep Power: 1
vasudha is on a distinguished road
Default file files by inode number

Every file has an unique inode number, using that we can identify that file. Create two files with similar name. i.e one file with a space at the end.

# touch "test-file-name"

# touch "test-file-name "
[Note: There is a space at the end]

# ls -1 test*
test-file-name
test-file-name


From the ls output, you cannot identify which file has the space at the end. Using option -i, you can view the inode number of the file, which will be different for these two files.

# ls -i1 test*
16187429 test-file-name
16187430 test-file-name


You can specify inode number on a find command as shown below. In this example, find command renames a file using the inode number.

# find -inum 16187430 -exec mv {} new-test-file-name \;

# ls -i1 *test*
16187430 new-test-file-name
16187429 test-file-name


You can use this technique when you want to do some operation with the files which are named poorly as shown in the example below. For example, the file with name — file?.txt has a special character in it. If you try to execute “rm file?.txt”, all the following three files will get removed. So, follow the steps below to delete only the “file?.txt” file.

# ls
file1.txt file2.txt file?.txt


Find the inode numbers of each file.

# ls -i1
804178 file1.txt
804179 file2.txt
804180 file?.txt


Use the inode number to remove the file that had special character in it as shown below.

# find -inum 804180 -exec rm {} \;

# ls
file1.txt file2.txt
[Note: The file with name "file?.txt" is now removed]
vasudha is offline   Reply With Quote
Old 10-30-09, 09:35 PM   #2
Unregistered
Guest
 
Posts: n/a
Thumbs up

you can also try using escape char for deleting it !

rm file\?

above two works well, hope this helps !

Thanks !
Siva
  Reply With Quote
Reply

Tags
file, files, inode, number

Thread Tools
Display Modes

Posting Rules
You may post new threads
You may post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads

Thread Thread Starter Forum Replies Last Post
How to auto extract rar files and join 001 files capri Desktop Computer 7 07-23-09 12:10 PM
Any one know this number? chriskabraham Airtel Mobile 5 06-09-09 07:00 PM
How to create a .cue files for (nfs underground 2) .bin files kartikoli Videogaming News and Reviews 5 05-30-08 06:18 PM
McAfee File Blocking - Cannot play/create/copy mp3 or other such files just4kix Computer hardware and software tips and tricks 0 04-11-08 12:24 AM
Data One...Number One..?? India Broadband BSNL broadband 0 07-18-06 12:51 AM


All times are GMT +5.5. The time now is 07:16 AM.


India Broadband Forum