1833924 Members
3109 Online
110063 Solutions
New Discussion

Re: removing file

 
SOLVED
Go to solution
andi_1
Frequent Advisor

removing file

Hi guys,

I have several files that were created with ^M at the end.

I can see the file, but when I do rm -rf dirName, it says dirName is not found.

If I try to cd dirName I have the same message.

How can I force to remove those files?

Thank you!
6 REPLIES 6
Martin Johnson
Honored Contributor
Solution

Re: removing file

try:

rm -i part.of.file.name*

or

rm -i *

type "n" until you get prompted for the file, then type "y".


Marty
Pete Randall
Outstanding Contributor

Re: removing file

Andi,

You can either use rm -i with a wild card (*) and answer no to all the files you're not after or you can do ls > file then edit the file to remove all the files you don't want to remove and put the rm in front of the ones you do.

Pete

Pete
harry d brown jr
Honored Contributor

Re: removing file


Try rm -ir dirName*

# mkdir hdhd^M
# ls -l|grep hdhd
drwxrwxrwx 2 root sys 96 Jun 14 10:13 hdhd
# rm -rf hdhd*
# ls -l hdhd
hdhd not found
# ls -l hdhd*
hdhd* not found
#


live free or die
harry
Live Free or Die
Helen French
Honored Contributor

Re: removing file

Using wildcard characters, you can do the task:

# cd dir_path
# rm -i * ( delete the ones you wanted to, when prompted)
Life is a promise, fulfill it!
Stefan Schulz
Honored Contributor

Re: removing file

Hi,

you could try rm -rf dirname* where dirname is only part of the real directoryname (without the ^M).

You can also use rm -rf "dirname". Where dirname is the full directoryname including the ^M. You should be able to produce the ^M with:

- - or
- -


Hope this helps

Regards Stefan
No Mouse found. System halted. Press Mousebutton to continue.
Sanjay_6
Honored Contributor

Re: removing file

Hi Andi,

Try this,

ls >test_file
vi test_file, remove unwanted entries. For the ones you want to remove, add rm in the front for the files and rm -r or rmdir for the directories. then execute this file,

sh test_file

Hope this helps.

Regds