LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-20-2007, 08:19 AM   #1
jimbob-2k7
LQ Newbie
 
Registered: Nov 2007
Posts: 7

Rep: Reputation: 0
Unhappy Can't delete a file ....


Hi All,

I've been searching on Google for a couple of hours and have not found anything that works

I'm trying to delete a file on FC6 using WinSCP/PuTTY.

When i use WinSCP to list the image directory I get:
Unexpected directory listing line '?--------- ? ? ? ? ? a56896.jpg'.
'?' is not a valid integer value

When i list it using the command line, it shows question marks:
--wxrwxr-x 1 root root 4875 Nov 30 2006 a56884.jpg
?--------- ? ? ? ? ? a56896.jpg

If i try and delete the file using the command line i get:
rm: cannot lstat `a56896.jpg': Unknown error 990

Hope someone can help?

Cheers,

Jim
 
Old 11-20-2007, 10:41 AM   #2
forrestt
Senior Member
 
Registered: Mar 2004
Location: Cary, NC, USA
Distribution: Fedora, Kubuntu, RedHat, CentOS, SuSe
Posts: 1,288

Rep: Reputation: 99
Try making a temporary directory one level above the one you are in. Move all the files in the directory you are in except for the one with the problem to the temp directory. Change directories up one level and rm -rf the directory you were in.

Code:
mkdir ../temp-directory-123
mv a56884.jpg ../temp-directory-123
(repeat above for each file in directory EXCEPT a56896.jpg)
cd ..
rm -rf directory-you-were-in
mv temp-directory-123 directory-you-were-in
When you are done you may want to boot to single user mode and run fsck on the drive.

HTH

Forrest

Last edited by forrestt; 11-20-2007 at 10:52 AM.
 
Old 11-21-2007, 06:52 AM   #3
jimbob-2k7
LQ Newbie
 
Registered: Nov 2007
Posts: 7

Original Poster
Rep: Reputation: 0
Hi Forrest,

Thanks for the info, one question, the directory has over 26k images, how do i move all the files except for the few with the problems?

Cheers,

Jim
 
Old 11-21-2007, 10:15 AM   #4
forrestt
Senior Member
 
Registered: Mar 2004
Location: Cary, NC, USA
Distribution: Fedora, Kubuntu, RedHat, CentOS, SuSe
Posts: 1,288

Rep: Reputation: 99
In the directory run "ls |wc -l" This will tell you the number of files and subdirectories in that directory. Then run "ls |grep \?|wc -l" this should tell you the number of files w/ corrupted names. There is a possibility that the questions marks aren't actually question marks and won't appear in the grep. If they don't, stop here and let me know. Next run "ls |grep -v \? |wc -l" this should tell you the number of files that DON'T have corrupted names. If the number of corrupted names looks about right, and the number of corrupted plus the number of uncorrupted is equal to the total, then:

Code:
% tcsh
% foreach FILE (`ls |grep \?`)
foreach? mv $FILE ../temp-directory-123
foreach? end
% exit
If the "tcsh" command above gives you problems, let me know and I'll give you instructions for another shell. If you are already running tcsh then you can skip the "tcsh" and "exit" above, but including them won't hurt anything.

Now, check the directory and make sure you haven't left any files that should not be deleted. If satisfied, continue with "cd .." in my previous post.

HTH

Forrest
 
Old 11-22-2007, 03:14 AM   #5
jimbob-2k7
LQ Newbie
 
Registered: Nov 2007
Posts: 7

Original Poster
Rep: Reputation: 0
Hi Forrest,

This is what i get:

ls |wc -l
36231

ls |grep \?|wc -l
0

You said stop if i have any problems

Cheers,

Jim
 
Old 11-22-2007, 04:45 AM   #6
indiancosmonaut
Member
 
Registered: Feb 2007
Posts: 65

Rep: Reputation: 15
Hi Jim,

Try removing the file using:

rm -rf ./'filename'
or
rm -rf -- 'filename'

indiancosmonaut
 
Old 11-22-2007, 09:09 AM   #7
jimbob-2k7
LQ Newbie
 
Registered: Nov 2007
Posts: 7

Original Poster
Rep: Reputation: 0
Hi indiancosmonaut,

When i try both commands i get:

rm: cannot lstat `a56896.jpg': Unknown error 990

Cheers.
 
Old 11-22-2007, 09:47 AM   #8
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 683Reputation: 683Reputation: 683Reputation: 683Reputation: 683Reputation: 683
Hopefully the directory is corrupt and not the filesystem. ( To the kernel, a directory is just a file )

If you use "ls -i" is the inode of the file listed?

You could use find to select the file with that inode and then delete it.
Code:
     find . -maxdepth 1 -inum <inode number> -okdir rm -f '{}' \;
By the way, I noticed that the file is owned by root. Please, please,please, don't run normally as root. There is no reason to do so in Linux.
 
Old 11-22-2007, 10:32 AM   #9
jimbob-2k7
LQ Newbie
 
Registered: Nov 2007
Posts: 7

Original Poster
Rep: Reputation: 0
Hi jschiwal,

Thanks 4 posting,

The images that are fine have a long number next to them, but the image that is corrupt has a 0 next to it, is that bad news?

Cheers,

Jim
 
Old 11-26-2007, 10:06 AM   #10
forrestt
Senior Member
 
Registered: Mar 2004
Location: Cary, NC, USA
Distribution: Fedora, Kubuntu, RedHat, CentOS, SuSe
Posts: 1,288

Rep: Reputation: 99
Sorry, that should have been "ls -l" not "ls" in the commands above. And the foreach also needs to be changed to:

Code:
%tcsh
% foreach FILE (`ls -l|grep \?|awk '{print $8}'`)
foreach? mv $FILE ../temp-directory-123
foreach? end
% exit
I'm sorry it took so long to get back to you.

HTH

Forrest

Last edited by forrestt; 11-26-2007 at 10:12 AM.
 
Old 11-26-2007, 10:31 AM   #11
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984
Quote:
Originally Posted by jimbob-2k7 View Post
The images that are fine have a long number next to them, but the image that is corrupt has a 0 next to it, is that bad news?
I don't know what exactly jschiwal had in mind, but actually an inode count equal to 0 is not a good one! When the inode number reaches 0, the file is cancelled or at least the filesystem doesn't know how to address it anymore. The message "Unknown error 990" make me think at a filesystem failure.
 
Old 12-03-2007, 08:52 AM   #12
jimbob-2k7
LQ Newbie
 
Registered: Nov 2007
Posts: 7

Original Poster
Rep: Reputation: 0
Hi Guys,

I've found the same problem in one of my backup folders

When i do 'ls -l' it says total 0, then i get a list of stuff like ablow and the file names have a red background ...

?--------- ? ? ? ? ? a?2440.jpg
?--------- ? ? ? ? ? a?2489.jpg
?--------- ? ? ? ? ? a?2526.jpg
?--------- ? ? ? ? ? a?2571.jpg
?--------- ? ? ? ? ? a?2625.jpg

Once again thanks for all your help

Cheers,

Jim
 
Old 12-03-2007, 09:28 AM   #13
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 67
How do you do your backups? Must be some sort of low-level backup to duplicate the corrupted directory...
 
Old 12-03-2007, 09:48 AM   #14
jimbob-2k7
LQ Newbie
 
Registered: Nov 2007
Posts: 7

Original Poster
Rep: Reputation: 0
well when i say backups ... i mean backup only done one up to now (i just dump the database every day and download it). We moved from our old host about a month or so ago ...

In WinSCP i select the folder, right click and Tar/Gzip ... so im starting to think if the problem started on the other server, or maybe during the transfer.

I only discovered this problem when i was trying to do a backup.

Cheers.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to delete a particular file from tar file majalee Linux - Software 2 07-12-2006 04:53 AM
how to delete .file? paschim Linux - General 5 10-20-2004 04:56 PM
Tried to delete file as root but it says I don't have permission to delete it! beejayzed Mandriva 23 03-12-2004 02:46 AM
Delete contents of the file, but not file? mikeshn Linux - General 9 05-28-2003 06:47 AM
file delete emperor13 Linux - General 1 12-06-2001 09:14 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:51 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration