Skip to content

How to Remove No-Name or Empty-Name Files

After you finish your shell scripting, you'd like to try your scripts to see the result in your test environment. In the debug phase, you will generate a lot of echo message to see where's problems, and maybe you will get some unrecognized files, like this:

$ ls -il
total 5
    709233 -rw-r--r--   1 oracle    dba           220 Aug 22 09:20
    709237 -rw-r--r--   1 oracle    dba            31 Aug 22 09:27
    709230 -rw-r--r--   1 oracle    dba          1917 Dec 25 09:07 Report.log
    573702 -rwxr--r--   1 oracle    dba           297 May 22 09:32
    490720 drwxr-xr-x   2 oracle    dba          3097 Jun 17 17:09 Check_Dir

As you can see, the first two files are no names. Actually, they do have names, they just can't be displayed and recognized from the console for some reasons. The only useful information they left us are inodes.

Before you delete those files, you may like to know the content of the no or garbled name files for sure to delete.

Next, we use find to identify the files to remove:

$ find . -inum 709233 -exec rm {} ;
$ find . -inum 709237 -exec rm {} ;

We succeeded to remove the no-name or empty-name file. Please note that, do not use rm -i, because -i stands for interactive, not inode.

Leave a Reply

Your email address will not be published. Required fields are marked *