LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 04-27-2009, 05:26 AM   #1
vjayraghavan
LQ Newbie
 
Registered: Feb 2009
Posts: 15
Blog Entries: 1

Rep: Reputation: 0
how to delete a file whose file name is \


hi,
I am not able to delete a file whose name is \

Quote:
rm \
Please help me to delete this file
 
Old 04-27-2009, 05:29 AM   #2
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847

Rep: Reputation: 128Reputation: 128
You've got a couple of options:
Code:
rm \\
rm '\'
should both do the trick.
 
Old 06-03-2009, 03:01 AM   #3
LinuxPimp
Member
 
Registered: Aug 2004
Distribution: Ubuntu Server Gutsy
Posts: 43

Rep: Reputation: 15
Quote:
Originally Posted by pwc101 View Post
You've got a couple of options:
Code:
rm \\
rm '\'
should both do the trick.
How about with "-" in the name?

The forward slash does not seem to "cancel" the "-" function.

Thanks

l
 
Old 06-03-2009, 03:06 AM   #4
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847

Rep: Reputation: 128Reputation: 128
If the file name has a - in the middle of the file, there's no need to escape (i.e. prefix with a \) the -, it's just an ordinary character, like a, or p.

For files which begin with a -, how to delete these is covered in the rm man page
Quote:
Originally Posted by man rm
To remove a file whose name starts with a `-', for example `-foo', use
one of these commands:

rm -- -foo

rm ./-foo
Suffice it to say, if you invoke rm with a --, anything after the -- is treated as a filename.

Last edited by pwc101; 06-03-2009 at 03:07 AM.
 
Old 06-03-2009, 03:25 AM   #5
LinuxPimp
Member
 
Registered: Aug 2004
Distribution: Ubuntu Server Gutsy
Posts: 43

Rep: Reputation: 15
Thank you very much!

l
 
Old 06-03-2009, 06:04 AM   #6
paul81
LQ Newbie
 
Registered: Feb 2008
Location: Rotterdam, Netherlands
Distribution: Fedora and Ubuntu
Posts: 14

Rep: Reputation: 1
If you're scared of throwing away the wrong files by using the 'rm' command, try using the -i flag. This will ask you for each file if you're sure you want to throw it away. In this way you can play around with the rm command and try using different flags without throwing away the wrong files.

$ rm -ri *
rm: remove directory `test'?
 
Old 06-03-2009, 07:26 AM   #7
onebuck
Moderator
 
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: SlackwareŽ
Posts: 13,923
Blog Entries: 44

Rep: Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158
Hi,

You can always use the 'man command' to get an idea of the command usage.

The 'man rm' does provide an example of the use.

I suggest that you also look at;

'Rute Tutorial & Exposition'
'Linux Documentation Project'
'LinuxSelfHelp'

These links and others can be found at 'Slackware-Links'. More than just SlackwareŽ links!
 
  


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
text match pipe to file then delete from original text file create new dir automatic tr1px Linux - Newbie 6 09-10-2008 09:40 PM
how to delete last number/word of a file and incude file count at the end of the chennaiguy Linux - Newbie 2 02-18-2008 09:08 PM
how to delete a particular file from tar file majalee Linux - Software 2 07-12-2006 04:53 AM
Tried to delete file as root but it says I don't have permission to delete it! beejayzed Mandriva 23 03-12-2004 02:46 AM
Delete contents of the file, but not file? mikeshn Linux - General 9 05-28-2003 06:47 AM

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

All times are GMT -5. The time now is 10:10 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