LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
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 08-28-2004, 01:15 AM   #1
henryluo
Member
 
Registered: Nov 2003
Posts: 36

Rep: Reputation: 15
how to delete a file name call "-D"


how to rm "-D" file name ,thanks
 
Old 08-28-2004, 01:17 AM   #2
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 372Reputation: 372Reputation: 372Reputation: 372
Use the cd command to enter the directory with the file, then execute:
Code:
rm ./-D
 
Old 08-28-2004, 02:44 AM   #3
henryluo
Member
 
Registered: Nov 2003
Posts: 36

Original Poster
Rep: Reputation: 15
thanks very much
 
Old 08-28-2004, 11:41 AM   #4
barisdemiray
Member
 
Registered: Sep 2003
Location: Ankara/Turkey
Distribution: Slackware
Posts: 155

Rep: Reputation: 30
Just an alternative way..
You can't delete the files beginning with `-' because it will be processed as a command line option wrongly. So you can use `--' switch to tell the program that there will be no command line option anymore, as in

Code:
[mbaris@slackware:~]$ touch -- -butterfly
[mbaris@slackware:~]$ rm -butterfly
rm: invalid option -- b
Try `rm --help' for more information.
[mbaris@slackware:~]$ rm -- -butterfly
rm: remove regular empty file `-butterfly'? y
[mbaris@slackware:~]$
There is always more than one way to do something in UNIX world ;-)
 
Old 08-28-2004, 02:40 PM   #5
student04
Member
 
Registered: Jan 2004
Location: Georgia
Distribution: OS X, CentOS
Posts: 669

Rep: Reputation: 34
or you can rename it, and then delete it.. (more effort, but another way :-D )

Code:
mv -D.jpg picture.jpg
rm -f picture.jpg
(there isn't a renaming command in linux, so you just move it to the same directory, giving it a new name
 
Old 08-28-2004, 02:58 PM   #6
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 372Reputation: 372Reputation: 372Reputation: 372
Actually, executing
Code:
mv -D.jpg picture.jpg
results in the same original problem. The mv command interprets "-D.jpg" as an option; not as a filename. It would work if you prefixed the -D with the current directory path ./ or the absolute path. That, however, would basically just work it's way back to a plain rm command.

And, just for a little info, there is a rename command. It's slightly different than what you might expect. You give rename specific text to replace, the text to replace it with, and then a list of files to perform the substitution on. For example
Code:
rename jpg jpeg *.jpg
That will rename every file in the current directory that ends with .jpg to end with jpeg. It will also replace jpg with jpeg if found within the filename itself. In other words, pic01.jpg will be renamed pic01.jpeg. vacation_jpg.jpg would be renamed vacation_jpeg.jpeg

You can read all about it with man rename
 
  


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
oops - made a file called "--dereference" - how do I delete it? BrianK Linux - General 2 06-21-2004 08:37 PM
How do you delete a file called "--tape-lengh=1"? I've tried everything... Huddlebum Linux - General 1 01-01-2004 10:11 PM
Can't locate object method "splitpath" via package "File::Spec" RobJohnston Linux - General 2 06-28-2003 09:59 AM
"Function not implemented" error in call to "sem_open()" Krishnendu8 Linux - Newbie 1 06-07-2003 02:52 AM
"Function not imlemented" error in call to "sem_open()" Krishnendu8 Linux - Networking 0 06-07-2003 02:19 AM


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

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