Dealing with Odd Filenames on the Commandline

July 7th, 2009 by Shawn Powers in

Your rating: None Average: 2.9 (7 votes)

Download in .ogv format
__________________________
Shawn Powers is an Associate Editor for Linux Journal. You might find him chatting on the IRC channel, or Twitter


Special Magazine Offer -- Free Gift with Subscription
Receive a free digital copy of Linux Journal's System Administration Special Edition as well as instant online access to current and past issues. CLICK HERE for offer

Linux Journal: delivering readers the advice and inspiration they need to get the most out of their Linux systems since 1994.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
JackAcid's picture

Command lineish

On July 9th, 2009 JackAcid (not verified) says:

Coud just use good old mc...

Troy Roberts's picture

How to remove files that start with a dash

On July 7th, 2009 Troy Roberts (not verified) says:

The simplest solution to removing a file beginning with a dash is to append ./ to the file name. So, to remove a file named "-" use: rm ./-

Gumnos's picture

Removing filenames that start with a dash

On July 8th, 2009 Gumnos (not verified) says:

This does work, but bash's wild-card expansion doesn't do this, so you can get caught by

rm *

where one of the filenames happens to be "-rf".

-gumnos

Gumnos's picture

Bane of filenames -- beginning with a dash

On July 7th, 2009 Gumnos (not verified) says:

The bane of my filename experiences are filenames that begin with a dash. They choke all sorts of command-line processing. Though many programs allow you to use a double-dash to separate command-line switches from filenames, not all programs support this convention. Little is as cruel as creating a file named "-rf /" and watching somebody try to remove that file...

Dan Fekete's picture

Dashes suck...

On July 7th, 2009 Dan Fekete (not verified) says:

Although I haven't dealt with it for a while, how does one deal with starting dashes? Would anyone be so kind as to post a script to find and change them to, say, an underscore?

In my previous experience I would have to change the name in gnome. But on servers with no X, this is a bit difficult.

Anonymous's picture

- files

On July 8th, 2009 Anonymous (not verified) says:

Dan I feel your pain. Does this provide relief: cd ..; rm subdir/-*; cd -

Post new comment

Please note that comments may not appear immediately, so there is no need to repost your comment.
The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <pre> <ul> <ol> <li> <dl> <dt> <dd> <i> <b>
  • Lines and paragraphs break automatically.

More information about formatting options

Newsletter

Each week Linux Journal editors will tell you what's hot in the world of Linux. You will receive late breaking news, technical tips and tricks, and links to in-depth stories featured on www.linuxjournal.com.
Sign up for our Email Newsletter

Tech Tip Videos

From the Magazine

December 2009, #188

If last month's Infrastrucuture issue was too "big" for you then try on this month's Embedded issue. Find out how to use Player for programming mobile robots, build a humidity controller for your root cellar, find out how to reduce the boot time of your embedded system, and if you're new to embedded systems find out the basics that go into one. You can also read about the Beagle Board, the Mesh Potato and a spate of other interestingly named items. And along with our regular columns don't miss our new monthly column: Economy Size Geek.







Read this issue