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 02-07-2006, 05: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, 05: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, 05:18 AM   #3
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 11,605

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


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


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