#AIX #delete #inode #rm #unix #inum #remove #inodenumber
Folders or files that cannot be removed using:
`rm <filename>`
because they have strange characters in the filename. For example, ^V or ~ or /. Then you can delete these files by using the inode name:
An inode identifies the file and its attributes such as file size, owner, and so on. A unique inode number within the file system identifies each inode. But, why delete a file by its inode number? Sure, you can use the rm command to delete a file. Sometimes, you accidentally create filenames with control characters or characters that cannot be input on a keyboard, or special characters such as ?, *, ^, etc. Removing filenames with such special characters can be a problem. Use the following method to delete a file with strange characters in its name: Please note that the procedure outlined below works with Solaris, FreeBSD, Linux, or any other Unix-like OS out there: Find out file inode First, find out the file's inode number with any one of the following commands:
`stat {file-name}`
OR
`ls -il {file-name}`
Use find command to remove file: Use the find command as follows to find and remove a file:
`find . -inum [inode-number] -exec rm -i {} \;`
When prompted for confirmation, press Y to confirm removal of the file. Delete or remove files with inode number Let us try to delete a file using its inode number. (a) Create a hard-to-delete filename:
`$ cd /tmp $ touch "\+Xy \+\8" $ ls`
(b) Try to remove this file with the rm command:
`$ rm \+Xy \+\8`
(c) Remove the file by its inode number, but first find out the file's inode number:
`$ ls -il`
Output:
```
781956 drwx------ 3 viv viv 4096 2006-01-27 15:05 gconfd-viv
781964 drwx------ 2 viv viv 4096 2006-01-27 15:05 keyring-pKracm
782049 srwxr-xr-x 1 viv viv 0 2006-01-27 15:05 mapping-viv
781939 drwx------ 2 viv viv 4096 2006-01-27 15:31 orbit-viv
781922 drwx------ 2 viv viv 4096 2006-01-27 15:05 ssh-cnaOtj4013
781882 drwx------ 2 viv viv 4096 2006-01-27 15:05 ssh-SsCkUW4013
782263 -rw-r--r-- 1 viv viv 0 2006-01-27 15:49 \+Xy \+\8`
```
Note: ``782263`` is the inode number. (d) Use the find command to delete the file by its inode: Find and remove the file using the find command, type the command as follows:
`$ find . -inum 782263 -exec rm -i {} \;`
Note: You can also add a \ character before the special character in the filename to remove it directly, so the command would be:
`$ rm "\+Xy \+\8"`
If you have a filename like ``2005/12/31`` then no UNIX or Linux command can delete this file by name. The only method to delete such a file is to delete the file by its inode number. Linux or UNIX never allows creating filenames like 2005/12/31, but if you are using NFS from Mac OS or Windows then it is possible to create such a file.
[[AIX, COMMANDS]]
[[Search for Files in AIX]]
[[Search for Files larger than 1GB in AIX]]