Unable to remove file using ‘rm’

aixfilesunix

In one of our severs (IBM AIX), we have a file in path /data/1002/ which we were not able to remove or delete using the 'rm' command. The error message we got is "rm: S1208001.002: A file or directory in the path name does not exist."

With the "-f" option, no error message was displayed, but the file is still there.

This file has a '0' byte size and when i use the command "touch S120801.002", i see two files with the same file name in that directory.

The directory listing is as below:

$ ls -l total 56
-rwxrwxrwx    1 oracle   dba               0 Feb 09 11:57 S1208001.002 
drwxrwxrwx    4 nobody   dba           24576 Feb 09 13:36 backup

How do I remove this bogus fie?

Thanks.

UPDATE 1

after using the touch command, the directory listing is as below:

$ ls -l total 56
-rwxrwxrwx    1 oracle   dba               0 Feb 09 11:57 S1208001.002 
-rwxrwxrwx    1 oracle   dba           77790 Feb 09 14:30 S1208001.002
drwxrwxrwx    4 nobody   dba           24576 Feb 09 13:36 backup

Best Answer

It sounds like this filename may contain a non-printable character. That would explain "touch" making a different file.

Try something like

       ls -b

in the directory to see if that's the case?

Then you should be able to do something like:

       rm -i S*2 

and it should prompt you for the file even with the hidden character.

Alternately, you may be able to use find to do this...

       find . -name S\*2 -exec /bin/rm -i {} \;

should prompt you for the files... I don't know if AIX 'find' syntax is unusual so this might not work, but the 'rm -i' part should let you abort the command if it's wrong.