Introduction
Files may have been uploaded or created with special characters in the file name making it difficult to remove those files.
Procedure
There are two approaches that can be made if they need to be remove. The first approach is to move the files into a folder that was created and then remove the folder.
Let's say the file names were junk\315N\ file1.doc and junk\315N\ file2.doc when you did "ls -al" in the folder containing those files. When doing to move or remove use a wildcard but be specific not to move other files.
mkdir oldfiles
mv junk*file*.doc
Then check the oldfiles folder and make sure it only contains what needs to be removed and then remove the folder.
rm -rf ./oldfiles
The second approach is to remove the files by inode number. The inode number can be obtained with "ls -ali".
For example:
#ls -ali
total 784
1710334 drwxrwxr-x 2 cpusr cpusr 4096 May 25 10:11 ./
1583143 drwxr-x---. 6 cpusr cpusr 69632 May 25 10:08 ../
1704888 -rw-r--r-- 1 cpusr cpusr 504832 Mar 18 2014 junk\315N\ file1.doc
1741723 -rw-r--r-- 1 cpusr cpusr 215552 Sep 15 2011 junk\315N\ file2.doc
#
The first column is the file inode number. Be very careful to copy the correct number and in that same folder use the following:
find . -inum <INODE NUMBER> -exec rm -i {} \;
In this case we want to remove the file with inode 1704888 and 1741723. The -i after rm is for interactive and will ask if you're sure before deleting the file. This is recommended.
find . -inum 1704888 -exec rm -i {} \;
results in
rm: remove regular file `junk\315N\ file1.doc'? y
and was answered with y so the file was removed.
Please be aware caution should be used while using these methods of server/systems administration. This information is provided as-is and isn't related to our software but may be useful in assisting with managing files in a Unix/Linux file system.
Comments
0 comments
Article is closed for comments.