Link to home
Start Free TrialLog in
Avatar of duncanb7
duncanb7

asked on

Linux rm command

Dear Experts,

Somehow, I found on my root directory in which it
has direcotry named ec2-user\r/ that I want
to delete it. But it can not do that by

rm -rf ec2-user\r

or
rm -rf  "ec-user\r"

Probably the directory is created by my wrong script with "\r" putting to the directory
name.

How I can I delete it

Pleaea advise
Duncan
ASKER CERTIFIED SOLUTION
Avatar of duncanb7
duncanb7

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of duncanb7
duncanb7

ASKER

it is solved suddenly on my command with rename $'\r' "" *

http://unix.stackexchange.com/questions/60779/how-do-i-remove-carriage-returns-from-directory-names
Duncan
Avatar of woolmilkporc
Just using single quotes would have been sufficient:

rm -rf  'ec-user\r'

The link you found deals with renaming, not removing (yet it helps).

Renaming can be done with single quotes as well:

mv 'ec-user\r' ec-user

wmp
if it can be renamed as normal direcotry name , it is of course that  can be deleted
Sure.

But why the extra effort of renaming before deleting when a single step is sufficient, just by using single quotes?
The thread is already closed
I just wanted to help. Sorry for bothering you.
Just want to reminder you the thread is closed so just worry you
did not see it. Anyway Thanks for your help