linux-admin.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Glynn Clements <glynn@gclements.plus.com>
To: "Darío Mariani" <mariani.dario@gmail.com>
Cc: linux-admin@vger.kernel.org
Subject: Re: How to delete a special directory
Date: Fri, 9 Feb 2007 18:07:14 +0000	[thread overview]
Message-ID: <17868.47186.7053.956709@cerise.gclements.plus.com> (raw)
In-Reply-To: <84bd26ef0702090915s7a40a9cbg1ea6b2a2db2a5d5@mail.gmail.com>


Darío Mariani wrote:

> > > >> I've accidently created two directories: -f and -q
> > > >>
> > > >> Now, i can't remove them with rm -rf -f -q
> > > >> I get an error.
> > > >>
> > > >
> > > > Try giving the full path name to the directory.  Such as,
> > > > rm -rdf ./-f ./-q
> > >
> > > Try this (works with bash on BSD...Linux should be the same)
> > >
> > >  rm -rf \-f \-q
> > >
> > > Make sure you are in bash...the backslashes escape the - and take it as a
> > > literal.
> >
> > That won't work. The dashes are significant to "rm", not the shell.
> > The backslashes will be removed by the shell, and won't affect the
> > arguments which "rm" sees.
> >
> > I have no idea why this would work on BSD; bash is bash, regardless of
> > the underlying OS.
> 
> What about rm -rf "-r" "-f"?

The same issue applies; the shell will simply "eat" the quotes before
passing the strings to "rm", which will interpret them as switches
rather than filenames.

Quotes and backslashes are shell syntax. They will help if the problem
is because the filename means something to the shell (e.g. a file
named "~" or "<" or "$foo"), but not if the filename means something
to the program (e.g. a file named "-f").

For that situation, you need to use "--" (which should work with any
program which uses getopt()), or the "./-f" trick.

-- 
Glynn Clements <glynn@gclements.plus.com>
-
To unsubscribe from this list: send the line "unsubscribe linux-admin" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2007-02-09 18:07 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-09 14:29 How to delete a special directory Mário Gamito
2007-02-09 14:33 ` Scott Pack
2007-02-09 15:01   ` Karey Weston
2007-02-09 16:59     ` Glynn Clements
2007-02-09 17:15       ` Darío Mariani
2007-02-09 18:07         ` Glynn Clements [this message]
2007-02-09 14:35 ` Florian Klien
     [not found] ` <200702090934.43065.doug@hunley.homeip.net>
2007-02-09 17:22   ` Mário Gamito

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=17868.47186.7053.956709@cerise.gclements.plus.com \
    --to=glynn@gclements.plus.com \
    --cc=linux-admin@vger.kernel.org \
    --cc=mariani.dario@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).