LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   how to delete a file whose file name is \ (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-delete-a-file-whose-file-name-is-%5C-721955/)

vjayraghavan 04-27-2009 06:26 AM

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

pwc101 04-27-2009 06:29 AM

You've got a couple of options:
Code:

rm \\
rm '\'

should both do the trick.

LinuxPimp 06-03-2009 04:01 AM

Quote:

Originally Posted by pwc101 (Post 3522232)
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

pwc101 06-03-2009 04:06 AM

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.

LinuxPimp 06-03-2009 04:25 AM

Thank you very much!

l

paul81 06-03-2009 07:04 AM

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'?

onebuck 06-03-2009 08:26 AM

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!


All times are GMT -5. The time now is 12:57 AM.