LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Failed Tar created "-M" file now can't delete (https://www.linuxquestions.org/questions/linux-general-1/failed-tar-created-m-file-now-cant-delete-718196/)

richinsc 04-10-2009 08:25 AM

Failed Tar created "-M" file now can't delete
 
Howdy Ya'll,

I have been using Linux for a number of years and frankly this one has me stumped, but while I have some ideas on how I can fix by taking down the server, I can't take the server off line because it is a production server.

There was a tar archive that failed and didn't know it. Until my /var ran out of disk space that is. Within /var there is a file name -M with a file size of 231M. At first I didn't realize it was a failed tar until I tried test extract it and discovered that it was a failed archive.

I have tried to rm, shred, mv, the file but all fail because the file keeps being seen as a command option.

Code:

ls -lh | more
total 231M
-rw-r--r--  1 root  root  231M 2009-03-25 13:54 -M

Code:

# rm -f -M
rm: invalid option -- M
Try `rm --help' for more information.

Code:

# shred -uvfz -M
shred: invalid option -- M
Try `shred --help' for more information.

Code:

# mv -M M
mv: invalid option -- M
Try `mv --help' for more information.

Code:

tar -tvf -M
-rw-r--r-- root/root 2147483647 2009-03-25 13:47:39 eng/backup.tar
tar: Unexpected EOF in archive
tar: Error is not recoverable: exiting now

Code:

# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1            1.1G  220M  808M  22% /
tmpfs                3.9G  8.0K  3.9G  1% /dev/shm
/dev/sda9            157M  47M  110M  30% /dsm
/dev/sda6            3.1G  517M  2.5G  17% /opt
/dev/sda10            111G  85G  26G  77% /tmp
/dev/sda7            4.1G  3.1G  931M  78% /usr
/dev/sda8            2.1G  1.9G  193M  91% /var

Now the issue also it likely to be due to the fact that eng/ no longer exists nor does the backup file in question. So I have a 231M file eating up valuable disk space and I can't remove it. My /var/ was at 97% but after deleting some logs that were WAY told old to be worth keeping... (I just realized to that my logs aren't rotating. :-( I will have to look into this) I deleted some achieved logs to free space.

No remember I can't take the server off line (It's Live Production), and I don't have any spare disk to move /var to larger pastures so any help or ideas to rid me of the blasted file would be most helpful. I just need it to not be interpreted as an option.

tronayne 04-10-2009 08:32 AM

One trick you can do (and be careful) is
Code:

rm -i *
and only answer "y" to that file.

Usually, though, you can get rid of those sort of things with
Code:

rm ./-M
or
rm -i ./*M                (and answer "y" or "n")

Hope this helps some.

richinsc 04-10-2009 08:42 AM

Thanks tronayne.

This one really had me stumped, never thought to use ./-M It worked like a charm Now I have much more space in my /var dir.. Now to work on my log rotation and figure out why it's isn't removing older archives...

colucix 04-10-2009 11:52 AM

Another way is
Code:

rm -- -M
the -- is valid for a lot of commands. It means the termination of the options section, that is every string coming after -- is interpreted as argument to the command, even if it begins with a hyphen. Very useful in this case.

custangro 04-10-2009 12:13 PM

Quote:

Originally Posted by colucix (Post 3504784)
Another way is
Code:

rm -- -M
the -- is valid for a lot of commands. It means the termination of the options section, that is every string coming after -- is interpreted as argument to the command, even if it begins with a hyphen. Very useful in this case.

Also...

Code:

root@host# rm "-M"
...That's why I love Linux...so many ways to do the same thing :D


All times are GMT -5. The time now is 08:53 PM.