Operating System - HP-UX
1834248 Members
2124 Online
110066 Solutions
New Discussion

Re: How to remove files with names containing "-"

 
SOLVED
Go to solution
Dave Walley
Frequent Advisor

How to remove files with names containing "-"

Hi.

I have managed to create a number of files containing the permissions in the name and have been unable to remove them the files are called as follows

-rw-rw----uat.000815:14:37

Any advice?.

Dave
why do i do this to myself
7 REPLIES 7
Victor BERRIDGE
Honored Contributor

Re: How to remove files with names containing "-"

Use the backslash:
rm -
Devbinder Singh Marway
Valued Contributor

Re: How to remove files with names containing "-"

try rm -i * ( i for interactive) and reply
y to the files you want to delete

or you can do ls -li to get the inode numbers
and then use find / -inum (numbers) -exec rm {} ;

laters
Dev
Seek and you shall find
Victor BERRIDGE
Honored Contributor

Re: How to remove files with names containing "-"

In your example it would be:
rm -rw*
Stefan Farrelly
Honored Contributor

Re: How to remove files with names containing "-"


To delete them use>

rm ./----14:32 etc.

(ie. put a fullstop followed by a forward slash before the filename)

Im from Palmerston North, New Zealand, but somehow ended up in London...
Kofi ARTHIABAH
Honored Contributor

Re: How to remove files with names containing "-"

Try the following:

# cd directory
# find . -name "*rw*" -exec ls -l {} \;

if those are the files you want to delete, then do:

# find . -name "*rw*" -exec rm {} \;

You should also be able to specify the names in quotes to remove them
# rm "-rw-rw*ua*"
nothing wrong with me that a few lines of code cannot fix!
Victor BERRIDGE
Honored Contributor

Re: How to remove files with names containing "-"

Sorry the backslash doenst show up (?) so put the backslash before the minus sign...
John Palmer
Honored Contributor
Solution

Re: How to remove files with names containing "-"

You can use the -- argument to rm (as well as a lot of other commands) to indicate to the program that the rest of the arguments are not command options. E.g.

rm -- -rw*