Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help removing file incorrectly named "-b"

Status
Not open for further replies.

Giwhiz

Technical User
Jan 7, 2009
2
US
I have a large file that is owned by root that is named -b and would like to know how to remove it. When I try to list the file using "ls -l" I get the listing for the whole directory. How can I remove only the file -b? I do have root access.

Thanks!

i.e.
-rw-r--r-- 1 root system 739645440 Jan 07 12:04 -b
drwxr-xr-x 39 root system 4096 Jan 07 14:08 .
drwxr-xr-x 24 root system 4096 Nov 03 11:28 ..
drwxrwxr-x 2 fred fred 256 Nov 12 11:00 fred
drwxrwxr-x 2 sue sue 256 Nov 12 11:00 sue
drwxrwxr-x 2 apps staff 256 Nov 12 11:00 apps
drwxrwxr-x 2 pkgs staff 256 Nov 12 11:00 pkgs
 
I figured out the answer to my question which is below:

$ ls -- -b
-b
$ rm -- -b
 
Hello,
You can remove this file with the inode_number find with:
ls -lia
and
in the FS ( if / or in /usr) for example
cd / or cd /usr
find . -inum "number_inode" -exec rm -i {} \;
or

rm -i \-b

-i for interactive response
 
hi,

rm "-b"

You ca use this method also when a filename contains spaces.

bye
vittorio
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top