LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Filename beginning with left bracket: file cannot be erased. (https://www.linuxquestions.org/questions/linux-newbie-8/filename-beginning-with-left-bracket-file-cannot-be-erased-846982/)

stf92 11-28-2010 01:30 AM

Filename beginning with left bracket: file cannot be erased.
 
Kernel 2.6.21.5, Slackware 12.0

Hi:
I saved a page from Linuxquestions. It was saved under a filename beginning with '[' (left square bracket). And I now can't delete the file. Unfortunately I cannot send you a screenshot because opening a terminal in the GUI makes ls behave differently. I shall try to describe, assuming the file is in dir '.'. Also let '[SOLVED]foo.html' be the file in question:
Code:

$ ls
<the file is listed>
$ ls [*
/bin/ls: cannot access [*: No such file or directory
$

If I want the hdd to get rid of this file, what should I do? Any hint will be welcome.

EDIT: my mistake. I got confused. The file has just been erased: 'rm -r [*'.

Nylex 11-28-2010 01:54 AM

For what it's worth, you could also have removed it by escaping the bracket, i.e. "rm \[...".

stf92 11-28-2010 02:00 AM

Yes, I tried that too. Only I was trying in the wrong directory! But, as I always have trouble distinguishing regexps from expresions to be interpreted by the shell, your observation is valuable, as I can now apply it as a general rule. Regards.


All times are GMT -5. The time now is 09:28 PM.