LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 12-08-2009, 10:38 AM   #1
jlarsen
Member
 
Registered: Jan 2005
Location: Dallas, TX
Distribution: Slackware 14.1
Posts: 80

Rep: Reputation: 15
trying to remove a file name \


I'm not sure how it got there, but a have a zero byte file that is bugging me:

-rw-r--r-- 1 someuser users 0 2009-12-07 11:35 \

This is a remote machine. If need be I'll install a VNC server on it and try KDE - but this is becoming a matter of curiosity now.

Here is what I have tried so far:
Code:
rm ./\
rm -- \
rm \\
rm '\'
- by the way touch '\' creates a file named \\

From what I read rm '\' seems like it should have worked but no luck. From the bash manual at gnu.org:

Quote:
3.1.2.1 Escape Character

A non-quoted backslash ‘\’ is the Bash escape character. It preserves the literal value of the next character that follows, with the exception of newline. If a \newline pair appears, and the backslash itself is not quoted, the \newline is treated as a line continuation (that is, it is removed from the input stream and effectively ignored).

3.1.2.2 Single Quotes

Enclosing characters in single quotes (‘'’) preserves the literal value of each character within the quotes. A single quote may not occur between single quotes, even when preceded by a backslash.
There must be simple solution to this one, but I can't seem to find it.
Thanks in advance.......
 
Old 12-08-2009, 11:00 AM   #2
pljvaldez
LQ Guru
 
Registered: Dec 2005
Location: Somewhere on the String
Distribution: Debian Wheezy (x86)
Posts: 6,094

Rep: Reputation: 281Reputation: 281Reputation: 281
http://www.cyberciti.biz/tips/delete...de-number.html
 
Old 12-08-2009, 11:00 AM   #3
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Quote:
- by the way touch '\' creates a file named \\
Not here.....

Starting with an empty folder:
Code:
[mherring@mystical play]$ touch \   ##the single \ is escaping the newline, so the shell simply waits for more input
> ^C
[mherring@mystical play]$ ls
[mherring@mystical play]$ touch \\    ##as you mention, this give the literal \
[mherring@mystical play]$ ls
\
[mherring@mystical play]$ rm \\
[mherring@mystical play]$ ls
[mherring@mystical play]$
 
Old 12-08-2009, 11:01 AM   #4
rn_
Member
 
Registered: Jun 2009
Location: Orlando, FL, USA
Distribution: Suse, Redhat
Posts: 127
Blog Entries: 1

Rep: Reputation: 25
try: rm ./\\
 
Old 12-08-2009, 11:48 AM   #5
jlarsen
Member
 
Registered: Jan 2005
Location: Dallas, TX
Distribution: Slackware 14.1
Posts: 80

Original Poster
Rep: Reputation: 15
@pixellany - you missed the single quotes - or maybe I should have used code tags to be more clear:

Code:
jeremy@testserver:~/testdir$ touch '\'
jeremy@testserver:~/testdir$ ls -l
total 0
-rw-r--r-- 1 jeremy users 0 2009-12-08 11:30 \\


pljvaldez seems to have hit the mark with the delete by inode solution. See below:
Code:
ls -il
total 276
394562 -rw-r--r-- 1 root root     0 2009-12-07 11:35 \

root@someserver:~# find . -inum 394562 -exec rm -i {} \;
rm: remove regular empty file `./ '? y
after which the file is gone. Interesting how it displays the empty file name.......
 
Old 12-08-2009, 01:09 PM   #6
sandmangnome
LQ Newbie
 
Registered: Dec 2009
Posts: 1

Rep: Reputation: 0
I think you might have had a <space> character in the filename that shows up as \<space> on the terminal
 
Old 12-08-2009, 01:41 PM   #7
jlarsen
Member
 
Registered: Jan 2005
Location: Dallas, TX
Distribution: Slackware 14.1
Posts: 80

Original Poster
Rep: Reputation: 15
Yeah, you are right! Proved it with a quick experiment:

Code:
root@testserver:/home/jeremy/testdir# touch ' '
root@testserver:/home/jeremy/testdir# v
total 0
-rw-r--r-- 1 root root 0 2009-12-08 13:42 \
root@testserver:/home/jeremy/testdir# rm ' '
root@testserver:/home/jeremy/testdir# v
total 0
root@testserver:/home/jeremy/testdir#

Last edited by jlarsen; 12-08-2009 at 01:43 PM. Reason: oops
 
Old 12-09-2009, 02:47 PM   #8
Valery Reznic
ELF Statifier author
 
Registered: Oct 2007
Posts: 676

Rep: Reputation: 137Reputation: 137
Quote:
Originally Posted by jlarsen View Post
Yeah, you are right! Proved it with a quick experiment:

Code:
root@testserver:/home/jeremy/testdir# touch ' '
root@testserver:/home/jeremy/testdir# v
total 0
-rw-r--r-- 1 root root 0 2009-12-08 13:42 \
root@testserver:/home/jeremy/testdir# rm ' '
root@testserver:/home/jeremy/testdir# v
total 0
root@testserver:/home/jeremy/testdir#
Another option:
Code:
rm -i ?
 
  


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 remove this file mokku Linux - Newbie 3 03-29-2008 01:34 PM
File showing with ? when using ls -al. How to remove file with only ? tacdog Red Hat 1 09-18-2007 10:12 AM
Bash remove part of a file based on contents of another file bhepdogg Programming 4 01-31-2007 03:13 PM
how to remove file -T odious1 Linux - General 1 08-11-2005 12:29 PM
c++ file processing -- how to remove a record from a file sharonyiisl Programming 4 09-26-2004 03:54 AM

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

All times are GMT -5. The time now is 09:07 PM.

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