Solved how to delete garbage file

Hi all:

When I play around tar/untar/gzip/gunzip, accidentally somehow it created a garbage file with file name:

Code:
----------  1 dave  staff  1111863812 Feb 23 18:51 ??v??Y?? ?????B*"?.??<???cog?*??z?Ee?O??d???@B?A2??v??m_??F???q?^H?{????;35???????B gj~?c?j?}!?{??@?

I tried to delete by command rm -f '.....' but it won't work. Any way I can clean it out?
 
The problem is that the filename does not contain question marks but unprintable characters that are being represented as question marks. There is the lengthy Thread cant-delete-file-with-strange-name.14612 that discusses the same issue and indicates that the shell commands one might expect to work, such as rm -i *, don't.

The most sensible suggestion I saw from that thread was to use a file manager program to delete the file. If you're not running a graphical environment, Midnight Commander, available from ports as misc/mc would be worth a go. If you are running X, you have a wider choice and something like x11-fm/rox-filer might do the job.

Otherwise, you could write a short program yourself that retrieves the filename and delete the file. Passing the filename directly should avoid any character translation issues that I suspect might be stopping the shell commands working properly. If writing it in C, useful functions from the Standard C Library would be readdir() (see the DIRECTORY(3) man page) and unlink(2).
 
Hello,

Which shell are you using? Generally if you write in the first character, and press "tab", it will automatically fill the rest of the file name (If you use shells/zsh, if you don't write the first character, press tab a few times, eventually the file with the weird name will come up).
Other solution is if it is a temporary folder, you can move any other file to another folder, delete the folder, recreate again, and move back the files. It is generally a good idea, that you create temporary folder for playing around.
 
Hello,

Which shell are you using? Generally if you write in the first character, and press "tab", it will automatically fill the rest of the file name (If you use shells/zsh, if you don't write the first character, press tab a few times, eventually the file with the weird name will come up).
Other solution is if it is a temporary folder, you can move any other file to another folder, delete the folder, recreate again, and move back the files. It is generally a good idea, that you create temporary folder for playing around.
tThanks. tThat was what iI did to have it deleted. bBut it is such "ugly" way to delete a file.
 
The problem is that the filename does not contain question marks but unprintable characters that are being represented as question marks. There is the lengthy Thread cant-delete-file-with-strange-name.14612 that discusses the same issue and indicates that the shell commands one might expect to work, such as rm -i *, don't.

The most sensible suggestion I saw from that thread was to use a file manager program to delete the file. If you're not running a graphical environment, Midnight Commander, available from ports as misc/mc would be worth a go. If you are running X, you have a wider choice and something like x11-fm/rox-filer might do the job.

Otherwise, you could write a short program yourself that retrieves the filename and delete the file. Passing the filename directly should avoid any character translation issues that I suspect might be stopping the shell commands working properly. If writing it in C, useful functions from the Standard C Library would be readdir() (see the DIRECTORY(3) man page) and unlink(2).
Really appreciate the advice, especially that discussion.
 
Back
Top