How to delete a special directory
Hi,
I've accidently created two directories: -f and -q
Now, i can't remove them with rm -rf -f -q
I get an error.
Any ideas ?
Warm Regards,
Mário Gamito
-
To unsubscribe from this list: send the line "unsubscribe linux-admin" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 5 lines · M?rio Gamito [[email protected]] 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
S.
Signature · 3 lines
-------------------------------------------------- Scott Pack [email protected]
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.
Cheers
wes
Quoted 14 lines · Scott Pack
Quoted 5 lines · M?rio Gamito [[email protected]] 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
S.
Quoted 9 lines · Karey Weston
Quoted 8 lines
Quoted 5 lines
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
Quoted 6 lines
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.
Signature · 1 line
Glynn Clements <[email protected]>
What about rm -rf "-r" "-f"?
If not, a file manager like Midnight Commander should do the trick.
Quoted 33 lines · Glynn Clements
Quoted 9 lines · Karey Weston
Quoted 8 lines
Quoted 5 lines
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
Quoted 6 lines
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.
--
Glynn Clements <[email protected]>
-
To unsubscribe from this list: send the line "unsubscribe linux-admin" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 16 lines · Darío Mariani
Quoted 16 lines
Quoted 15 lines
Quoted 8 lines
Quoted 5 lines
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.
Quoted 8 lines
Quoted 6 lines
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.
Signature · 5 lines
Glynn Clements <[email protected]> - To unsubscribe from this list: send the line "unsubscribe linux-admin" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 6 lines · Mário Gamito
I've accidently created two directories: -f and -q
Now, i can't remove them with rm -rf -f -q
I get an error.Any ideas ?
try: rm -rf -- -f -q
that should do it. with the double dash you end the commands for rm.
hth
florian
Signature · 12 lines
Florian Klien student of Telematics, tutor for 'Introduction to Structured Programming' and 'Software Development Practical Exercises' at Graz university of technology. "We have persistent objects, they're called files.", Ken Thompson - To unsubscribe from this list: send the line "unsubscribe linux-admin" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): [email protected]
Hi,
Thank you all for your answers.
Yhis did the trick :)
Quoted 1 line
/bin/rm-r -- ./-f ./-q
Warm regards,
Mário Gamito
-
To unsubscribe from this list: send the line "unsubscribe linux-admin" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html