Solved

Linux rm command

Posted on 2013-11-10
8
418 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…

803 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