Computing.Net > Forums > Solaris > how to rm a file '-'

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

how to rm a file '-'

Reply to Message Icon

Name: George
Date: May 30, 2003 at 00:57:32 Pacific
OS: solaris
CPU/Ram: sparc
Comment:

"touch - " created a file '-',
now how to delete this file,
as "rm -options - " is not accepted.
Thanks from gping



Sponsored Link
Ads by Google

Response Number 1
Name: jonob
Date: May 30, 2003 at 02:26:05 Pacific
Reply:

Hello


Try rm -r ./-

Jonob


0

Response Number 2
Name: David Perry
Date: May 30, 2003 at 04:27:54 Pacific
Reply:

From the man page on rm, you need to use 2 "-" characters.

NOTES
A -- permits the user to mark explicitly the end of any command line options, allowing rm to recognize file arguments that begin with a -. As an aid to BSD migration, rm will accept - as a synonym for --. This migration aid may disappear in a future release. If a -- and a - both appear on the same command line, the second will be interpreted as file.


0

Response Number 3
Name: GulDukat
Date: June 6, 2003 at 00:51:34 Pacific
Reply:

Deleting file "-" is little tricky in Solaris since the dash is confusing the rm command because it seems that you will provide a flag.

these are the steps to take deleting file like that.

1) #ls -il -

the command will get the inode of the file and the result will look like this

126 wr-xwr-r -- -- - "-"

* note 126 is the inode of the file

2) using find command and the inode


#find /- -inum 126 -exec rm {} \;

* after the / include the - because there could be other files that have the same inode in other directories and you dont want to delete them.

I guess that will solve your problem


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Solaris Forum Home


Sponsored links

Ads by Google


Results for: how to rm a file '-'

How to make a boot disk for solaris www.computing.net/answers/solaris/how-to-make-a-boot-disk-for-solaris/3457.html

New user, how to buy a low budget wkstn? www.computing.net/answers/solaris/new-user-how-to-buy-a-low-budget-wkstn/2073.html

How to make a user www.computing.net/answers/solaris/how-to-make-a-user/4831.html