Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am not sure how or when the below folder was created.. But I am unable to delete or open it..

bash-3.2$ cd '+%d-%m-%y'
bash: cd: +%d-%m-%y: No such file or directory
bash-3.2$ rm -f  '+%d-%m-%y'
bash-3.2$ ls -l | grep "+"
drwxr-xr-x   2 hypess   hypess         2 Dec 20 04:21 +%d-%m-%y
share|improve this question
add comment

migrated from stackoverflow.com Apr 5 '13 at 11:14

This question came from our site for professional and enthusiast programmers.

1 Answer

up vote 2 down vote accepted

Use single quotes. Not double quotes. Also use -r to remove directories:

rm -r '+%d-%m-%y'

Not There may be some (leading or) trailing whitespace. You can reveal this using:

ls -l | grep "+" | cat -vet

Ensure you capture all of the whitespace in the quotes.

How it was created? hypess used single quotes, presumable after a malformed date command.

When it was created? Around 2 Dec 20 04:21, I suspect.

share|improve this answer
    
Updated my question. That is not the issue... –  Kent Pawar Feb 4 '13 at 12:23
    
@KentPawar: I've updated my answer accordingly. I'm not sure it warranted a downvote as it was a reasonable response to the question as it stood at the time with double-quotes. –  Johnsyweb Feb 4 '13 at 12:26
    
Thanks @Johnsyweb! Turns out the script was using Windows EOL and so the folder '+%d-%m-%y^M$' was created along with the CR special character.. –  Kent Pawar Feb 4 '13 at 12:40
    
Nasty! Glad you found it. –  Johnsyweb Feb 4 '13 at 12:47
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.