tags:

views:

38

answers:

3

A command I executed in cygwin hosed up a bunch of files. Now I cannot delete them. Omitting most of the 'ls' output, here is what I'm dealing with:

% ls -l
ls: cannot access WSERV001.txt: No such file or directory
-rw-r--r--  1 mccppk mkgroup-l-d   50 Sep 17 16:57 WSERV001.text
??????????? ? ?      ?              ?            ? WSERV001.txt
% rm WSERV001.txt
rm: cannot remove `WSERV001.txt': No such file or directory
% touch WSERV001.txt
touch: cannot touch `WSERV001.txt': Permission denied

The .text file is normal. The .txt file (directory entry anyway) is obviously hosed. Any ideas on how to get the .txt file deleted?

+1  A: 

As admin, this should fix:

chown <yourusername> WSERV001.txt
chmod 666 WSERV001.txt
rm -f WSERV001.txt

If not, you might have disk errors.

Joshua
A: 

Attempts to use chown and chmod, even as root, failed (I don't recall the error).

I'm pretty sure my disk is fine. I run DiskCheckup daily for a strong history of SMART settings, and checked it this morning. No worries there.

Since the original problem and post, I got busy, and just now got back to that same local shell window. Those files were gone. This was a local cygwin shell on my laptop, so I know that no one else "helped". Strange. Those .txt files were just not there anymore.

I'm still curious what would cause ls to output all question-marks like that for all of the file metadata, except for the filename. But the main issue is resolved.

MikeC
Easy. File that is failing stat(2) because it isn't really there or has a pending delete operation.
Joshua
A: 

Hi, I had the same problem and fixed it as follow (under Win7):

Open a cmd windows (run as Administrator)

takeown /r /f DRIVE:\PATH

icacls DRIVE:\PATH /grant USERNAME:F /T

where USERNAME is your win7 username under which you are running this.

Also make sure cron.exe is NOT running for user USERNAME or SYSTEM (can be checked from the TaskManager) and that no programs from cygwin are running.

Once all has been checked and done, you should be able to delete your files.

Hope this helps,

Jean

Jean
Thanks, Jean. I'm not running Win7, but perhaps your solution will help others who are.
MikeC