Solved

Linux rm command

Posted on 2013-11-10
8
424 Views
Last Modified: 2013-11-10
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
0
Comment
Question by:duncanb7
  • 5
  • 3
8 Comments
 
LVL 13

Accepted Solution

by:
duncanb7 earned 0 total points
ID: 39636825
Finally solved it by first rename it
rename $'\r' '' *
0
 
LVL 13

Author Closing Comment

by:duncanb7
ID: 39636828
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
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 39636860
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
0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
LVL 13

Author Comment

by:duncanb7
ID: 39636873
if it can be renamed as normal direcotry name , it is of course that  can be deleted
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 39636889
Sure.

But why the extra effort of renaming before deleting when a single step is sufficient, just by using single quotes?
0
 
LVL 13

Author Comment

by:duncanb7
ID: 39636895
The thread is already closed
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 39636900
I just wanted to help. Sorry for bothering you.
0
 
LVL 13

Author Comment

by:duncanb7
ID: 39636917
Just want to reminder you the thread is closed so just worry you
did not see it. Anyway Thanks for your help
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question