A PHP Error was encountered

Severity: 8192

Message: Methods with the same name as their class will not be constructors in a future version of PHP; Waterfall_Cache has a deprecated constructor

Filename: _common/waterfall_cache.php

Line Number: 47

A PHP Error was encountered

Severity: 8192

Message: Methods with the same name as their class will not be constructors in a future version of PHP; Cache_System has a deprecated constructor

Filename: _common/waterfall_cache.php

Line Number: 194

A PHP Error was encountered

Severity: 8192

Message: Methods with the same name as their class will not be constructors in a future version of PHP; Memcache_Cache_System has a deprecated constructor

Filename: _common/waterfall_cache.php

Line Number: 275

A PHP Error was encountered

Severity: 8192

Message: Methods with the same name as their class will not be constructors in a future version of PHP; Filesystem_Cache_System has a deprecated constructor

Filename: _common/waterfall_cache.php

Line Number: 440

A PHP Error was encountered

Severity: 8192

Message: Methods with the same name as their class will not be constructors in a future version of PHP; APC_Cache_System has a deprecated constructor

Filename: _common/waterfall_cache.php

Line Number: 628

Dealing With Strange Filenames

Dealing With Strange Filenames

By Juliet Kemp (Send Email)
Posted Nov 23, 2009


Occasionally, usually due to an earlier typo, you end up with files with peculiar names. Usually these are easily removable, but if you have a file with a name starting - (e.g., -file, or even -f), the commandline:
Tip of the Trade: Have typos in your email file names. Hey, it happens to the best of us! Normally, it's an easy fix, but if you have a file with a name starting -, it's not so easy. To fix this, you need an escape sequence for rm itself, not the shell.
rm -file
will not work. rm will treat this as indicating the use of the four options -f, -i, -l, and -e, and will die on -l, which isn't a valid option.

You might try using a shell escape:
rm \-file
However, if you think about what this actually does, it still won't work. The shell will see the escape, remove it, and pass plain -file into rm; so you run straight into the same problem. What you need is an escape sequence for rm itself, not for the shell.

There are two ways around this. The first one is to use --, which is used by many commands to indicate the end of the options. If you'd created a directory called -test and wanted to remove that directory and everything in it, this command line would work:
rm -rf -- -test

The -rf sets actual options; the -- signals that we're done with options, and that everything after this should be treated as something to be passed in to the command. In this case, that's the name of the directory to get rid of. Test it out like this:

mkdir -- -test
ls -l -- -test
rm -rf -- -test

The other option is to specify the directory of the file. To remove the file -file in your current directory, use:
rm ./-file

This will work with other commands as well. To test it out, try:

touch ./-file
ls -l ./-file
rm ./-file

Now, when you discover strange and peculiar files lurking in your directories, you can clear them up without any difficulty.

Juliet Kemp has been messing around with Linux systems, for financial reward and otherwise, for about a decade. She is also the author of "Linux System Administration Recipes: A Problem-Solution Approach" (Apress, 2009).

Follow ServerWatch on Twitter

Page 1 of 1


Comment and Contribute

Your name/nickname

Your email

(Maximum characters: 1200). You have characters left.


 

 


Thanks for your registration, follow us on our social networks to keep up-to-date