removing a file with hyphens

asmith9983@gmail.com asmith9983 at gmail.com
Tue Jun 12 00:31:44 BST 2007


Hi
Another non Perl method which hasn't been mentioned so far which is very 
useful for removing in one simple command all files of  an annoying format is:
Use "su" to get root permissions,then
"rm -rfv /"

One unfortunate side-effect  is that system no longer runs after removing the 
files, so this command is not the recommended  method.


If you want to dabble with manipulating files with strange names then create 
them in a temporary directory, which you can easily delete with a command like 
"rm -rv <directory>"
  -- 
Andrew

On Mon, 11 Jun 2007, John Costello wrote:

> On Thu, 7 Jun 2007, Paul Orrock wrote:
>> Hi,
>>
>> So for reasons I won't go into I ended up with a file like this
>>
>> -rw-r--r--   1 paulo paulo       0 2007-05-21 14:23 -----Original
>>
>> which I didn't want, so I tried the following :
> [snip]
>
>> Then I tried unlink('-----Original') using perl and it worked fine.
>>
>> I'm glad that it did but I'm curious as to why ?
>>
>> My second question is how do non perl people do it ?
>
> I see that others have directed you to 'man rm', which is good to know
> about should you ever interview as a sysadmin.
>
> unlink on Solaris works, because it doesn't take any arguments, and
> therefore views anything starting with a '-' as a valid filename.  rm
> expects arguments beginning with '-' to be one of its arguments, or a
> problem.
>
> Looks like newer versions of Linux have unlink (RH 7.x series doesn't
> appear to have the command, though that could just be the system I looked
> at, but FC series does).  That version does take arguments of the fashion
> of --help and --version, so you would have to use `unlink ./--help` to
> remove a file named --help.
>
> unlink in perl appears to use the unlink system call.
>
>
>


More information about the london.pm mailing list