Results 1 to 2 of 2

Thread: file files by inode number

  1. #1
    Junior Member
    Join Date
    Jul 2009
    Liked
    0 times
    Posts
    16

    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]

  2. #2
    Unregistered
    Guest

    Thumbs up

    you can also try using escape char for deleting it !

    rm file\?

    above two works well, hope this helps !

    Thanks !
    Siva

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Review | Teracopy | Copy and move files at high speed
    By itsmemad in forum Software News, Previews and Reviews
    Replies: 2
    Last Post: 04-27-10, 11:05 PM
  2. Replies: 0
    Last Post: 02-13-10, 02:41 PM
  3. Swaps Partition and files cool and optimize way
    By Luke Skywalker in forum Operating Systems
    Replies: 0
    Last Post: 02-12-10, 11:24 PM
  4. Remove Password Protection From PDF Files
    By deepmohan in forum Software News, Previews and Reviews
    Replies: 0
    Last Post: 02-10-10, 01:01 PM
  5. How Torrents Works ?
    By talktoanil in forum Computer technology
    Replies: 12
    Last Post: 02-03-10, 01:26 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •