LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 09-12-2006, 11:00 PM   #1
julian1972
LQ Newbie
 
Registered: Jun 2005
Posts: 4

Rep: Reputation: 0
problematic file name


Hi

I downloaded a file with a name starting with a hyphen,
and I am having a whole lot of problem dealing with it
because every command I used with it wanted to treat it
as some kind of flag. Eventually, I used Konqueror to
rename it, but the whole experience made me wonder if it
is possible to work with such a filename in a shell.
Suggestions?

Thanks.
 
Old 09-12-2006, 11:21 PM   #2
KenJackson
Member
 
Registered: Jul 2006
Location: Maryland, USA
Distribution: Fedora and others
Posts: 756

Rep: Reputation: 144Reputation: 144
One easy way is to add a leading "./".
Some commands have an "-f" switch that means a filename follows.
Some commands accept "--" (two dashes) as a switch to mean that no more switches follow.
If the remainder of the filename is fairly unique, you may be able to replace the '-' with a '?'.
 
Old 09-12-2006, 11:22 PM   #3
rickh
Senior Member
 
Registered: May 2004
Location: Albuquerque, NM USA
Distribution: Debian-Lenny/Sid 32/64 Desktop: Generic AMD64-EVGA 680i Laptop: Generic Intel SIS-AC97
Posts: 4,250

Rep: Reputation: 62
Just guessing: Enclose it in quotes, or put a \ right in front of the -
 
Old 09-12-2006, 11:23 PM   #4
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,507

Rep: Reputation: 128Reputation: 128
The best way is simply to use ./-filename, as KenJackson said. Stumped me for a while too.
 
Old 09-12-2006, 11:34 PM   #5
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Ubuntu 12.04, Antix19.3
Posts: 3,794

Rep: Reputation: 282Reputation: 282Reputation: 282
If you have a look at the man pages for i.e. rm and mv, the option list can be terminated by '--'.
So mv -- -xxx.txt yyy.txt will move the file -xxx.txt to yyy.txt without problems.

[edit]bit slow[/edit]

Last edited by Wim Sturkenboom; 09-12-2006 at 11:36 PM.
 
Old 09-13-2006, 09:58 PM   #6
julian1972
LQ Newbie
 
Registered: Jun 2005
Posts: 4

Original Poster
Rep: Reputation: 0
Thanks for all your help.

And fyi, quotes and \ would not work because they just protect the string from the shell, and
do not modify how the program, be it mv or rm, would parse the name.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
What should I do Problematic Inspiron 6000 derrekito Linux - Laptop and Netbook 1 09-20-2005 02:28 PM
problematic case statement alaios Programming 4 08-24-2005 10:05 AM
Gentoo install...Problematic whoever Linux - Newbie 15 08-09-2005 12:44 PM
udev 064 still problematic xushi Slackware 6 07-27-2005 03:14 PM
newb needs help with some problematic hardware sgcam2000 Debian 3 06-24-2004 04:47 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

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