The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Operating Systems
> Linux Help
|
Deleting file with back slash in name
Discuss Deleting file with back slash in name in the Linux Help forum on Dev Shed. Deleting file with back slash in name Linux Help forum discussing topics including usage, troubleshooting, modules, and distributions. Linux is an open source OS, based on UNIX.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

November 28th, 2011, 10:30 PM
|
|
Contributing User
|
|
Join Date: Feb 2009
Location: United States
|
|
|
Deleting file with back slash in name
I somehow created a file called "\ --directory" in the / directory of my server. I created it trying to create a tar file from the command line...I'm not sure what I had typed exactly since I did it a few hours ago.
I can't figure out how to delete it, no matter what I try it says "no such file or directory".

|

November 29th, 2011, 04:01 AM
|
|
|
When trying to deleet files with bizarre names, containing special characters I tend to tread carefully and use the ls command first to find out just what the shell will accept. Once I can list the file I will change the ls to rm. Anyway, try:
Code:
rm "\\ \-\-directory"
__________________
The moon on the one hand, the dawn on the other:
The moon is my sister, the dawn is my brother.
The moon on my left and the dawn on my right.
My brother, good morning: my sister, good night.
-- Hilaire Belloc
|

November 29th, 2011, 05:01 PM
|
|
Contributing User
|
|
Join Date: Feb 2009
Location: United States
|
|
That doesn't work either. It simple gives me
Code:
rm: cannot lstat `\\ \\-\\-directory': No such file or directory
|

November 29th, 2011, 06:18 PM
|
|
|
I hate trying stuff like this ...! As I said, messing about with an ls command can work wonders ... sometimes you need to 'quote' spaces (such as (\ ), sometimes having them in quotes (" ") is enough.
What do:
Code:
ls "\\ *"
ls "\\\ *"
ls "*directory"
return?
|

November 29th, 2011, 06:58 PM
|
|
|
If the file is named
then use this to remove it
Also, if you have mc installed on your linux box you can let mc do the hard work of parsing the filename, you just have to arrow the selection bar over the offending file and delete it.
__________________
======
Doug G
======
It is a truism of American politics that no man who can win an election deserves to. --Trevanian, from the novel Shibumi
|

November 29th, 2011, 10:30 PM
|
|
Contributing User
|
|
Join Date: Feb 2009
Location: United States
|
|
I went the MC route (I've never heard of this, so thanks!).
Even
Code:
rm "\\ --directory"
didn't work. But it's fixed now, again many thanks guys.
|

November 29th, 2011, 10:55 PM
|
|
|
|
I find mc indispensable for command-line work. It's the first thing I add on a new linux system.
You might have had a non-printing character in your filename. I once had a filename that had embedded a couple ctrl-H (backspace) that hid the complete filename. The cursor backed up and overwrote a couple characters that you couldn't see.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|