TIP file starting with dash
From Gentoo Linux Wiki
| Terminals / Shells • Network • X Window System • Portage • System • Filesystems • Kernel • Other |
- This page is a candidate for deletion
- Reason given: Duplicate of TIP Dealing with files that start with a dash
- If you disagree with its deletion, please explain why on its discussion page.
- If you intend to fix it, please remove this notice, but do not remove this notice from articles that you have created yourself.
- Make sure no other pages link here and check the page's history before deleting.
Very small tips to manipulate files starting with a dash (-) with bash.
[edit] The problem
Typically when an emerge fails, it leaves a directory like:
/var/db/pkg/sys-libs/-MERGING-glibc-2.3.3.20040420-r2
If I change to the directory /var/db/pkg/sys-libs/
cd /var/db/pkg/sys-libs/
I can't remove the file by simply doing:
rm -MERGING-glibc-2.3.3.20040420-r2
Since the name begins with a dash, rm (and all the other commands) believe that 'M' is a parameter, which isn't right.
[edit] The solution
Simply add ./ before the name to avoid this problem.
rm ./-MERGING-glibc-2.3.3.20040420-r2
Or add -- after the command to indicate end of options.
rm -- -MERGING-glibc-2.3.3.20040420-r2
[edit] Resources
- Unix Power tools book
