LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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 02-07-2006, 04:02 AM   #1
vjimin
LQ Newbie
 
Registered: Nov 2005
Posts: 8

Rep: Reputation: 0
Question Handling filename beginning with '--' in bash


Hello,

I accidentally created a filename that begins with `--exclude` (while running a careless tar command).

Now, everytime I try to rename or delete this file, I get an error:

Code:
unrecognized option `--exclude=`
I believe the mv and rm commands treat this as an option, regardless of whether I put it inside quotes or escape it with backslashes.

Can anyone please tell me how to get rid of this odd file? FYI, I'm on bash.

Thanks in advance,
VJ
 
Old 02-07-2006, 04:18 AM   #2
vjimin
LQ Newbie
 
Registered: Nov 2005
Posts: 8

Original Poster
Rep: Reputation: 0
Sorry, found a solution myself. I'm blind... it was right there in the rm man page. Had to use either:

Code:
rm -- -foo

rm ./-foo

VJ
 
Old 02-07-2006, 04:18 AM   #3
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Use the "--" before the filename to terminate the list of options:
Code:
mv -- --exclude 
or
rm -- --exclude
 
  


Reply



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
bash integer handling question mikee78 Programming 11 11-14-2005 04:53 AM
Getting the first part of a filename in a BASH script trevelluk Programming 3 02-15-2005 01:06 AM
using bash in cron to get the date in filename rstoutmna Programming 1 12-29-2004 02:39 PM
Signal handling from bash shy Programming 2 11-20-2004 08:41 AM
handling whitespaces in bash guerilla fighta Linux - General 2 01-25-2003 04:12 PM

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

All times are GMT -5. The time now is 07:53 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
Open Source Consulting | Domain Registration