How to manipulate files with name like ‘-life.mp3’

March 21st, 2007 mysurface Posted in Common, mplayer, mv, rm | Hits: 56581 | 4 Comments »

Sometimes, you may find some file you can’t delete because of the filename begins with minus(-). LBE have that example on the post “Remove file start with special character”, as simple as this

rm ./-life.mp3

The same way you can manipulate those files by mv, cp etc. The important highlights here is ./
dot(.) is actually means current directory and slash (/) is actually use to escape the minus(-). Without escaping the minus(-), linux commands will treat it as an option argument.


mplayer ./*.mp3 

Is actually play all mp3 including those mp3 files with filename start with minus(-).

[tags]command, tips[/tags]

4 Responses to “How to manipulate files with name like ‘-life.mp3’”

  1. ?!

    rm — -life.mp3

    It’s a feature of gnu getopt, IIRC.

  2. Or you could try
    rm — -life.mp3

  3. […] Por cierto este truco lo he leido en Linux by Examples y tiene algun que otro comando interesante. Consultad su web (en ingles). […]

  4. Surprisingly challenging thank you, I presume your trusty audience could very well want a good deal more reviews like that keep up the good work.

Leave a Reply