Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 20 Sep 2002 09:19:13 +0100
From:      Matthew Seaman <m.seaman@infracaninophile.co.uk>
To:        mingo lu <freebiebsd@yahoo.com>
Cc:        freebsd-questions <freebsd-questions@FreeBSD.ORG>
Subject:   Re: weird files
Message-ID:  <20020920081913.GA97223@happy-idiot-talk.infracaninophi>
In-Reply-To: <20020920023650.65864.qmail@web14805.mail.yahoo.com>
References:  <20020920023650.65864.qmail@web14805.mail.yahoo.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Sep 19, 2002 at 07:36:50PM -0700, mingo lu wrote:

> i have two weird files under my home directory; one is
> file named "-bash.gmon" and another one is "xy ds".
> how could i remove them? rm just won't work ...

There's two different gotchas you're experiencing here.

i) File names that start with '-', or somehow look like program
options.  There are two general ways to get around this:

    Give a path relative to the current directory:

    rm ./-bash.gmon

    or use the special 'end of options' option '--':

    rm -- -bash.gmon

This is described very clearly in the Note at the end of the rm(1) man
page.

ii) File names with spaces, brackets, ampersands or other characters
of syntactical significance to the shell.  In general, you can use any
characters you like in a unix filename, except for '/' (the directory
separator) and NULL (which marks the end of the filename).  However
the programs that you use to interact with the filesystem may take a
more restricted view.

Unix shells however have a quoting mechanism to override their own
special interpretation of such characters.  You can either enclose the
whole file name in quotation marks or use a \backslash to escape the
character:

    rm "xy ds"

    rm xy\ ds

There's a lot more to shell quoting than that -- and different shells
have different behaviours with certain characters, particularly csh(1)
and tcsh(1) and the exclamation mark! Shells with filename completion
will usually automatically quote filenames for you.

	Cheers,

	Matthew

-- 
Dr Matthew J Seaman MA, D.Phil.                       26 The Paddocks
                                                      Savill Way
                                                      Marlow
Tel: +44 1628 476614                                  Bucks., SL7 1TH UK

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020920081913.GA97223>