LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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, 11:38 AM   #1
jlarsen
Member
 
Registered: Jan 2005
Location: Dallas, TX
Distribution: Slackware 14.1
Posts: 79

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, 12:00 PM   #2
pljvaldez
LQ Guru
 
Registered: Dec 2005
Location: Somewhere on the String
Distribution: Debian Wheezy (x86)
Posts: 6,094

Rep: Reputation: 271Reputation: 271Reputation: 271
http://www.cyberciti.biz/tips/delete...de-number.html
 
Old 12-08-2009, 12:00 PM   #3
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
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, 12:01 PM   #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, 12:48 PM   #5
jlarsen
Member
 
Registered: Jan 2005
Location: Dallas, TX
Distribution: Slackware 14.1
Posts: 79

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, 02: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, 02:41 PM   #7
jlarsen
Member
 
Registered: Jan 2005
Location: Dallas, TX
Distribution: Slackware 14.1
Posts: 79

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 02:43 PM. Reason: oops
 
Old 12-09-2009, 03:47 PM   #8
Valery Reznic
ELF Statifier author
 
Registered: Oct 2007
Posts: 675

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


All times are GMT -5. The time now is 06:37 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration