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 have these tricky directories that I can't figure out how to delete. If I run

ls -ld *

I get…

drwxrwxr-x 7 user1 taskfmri 2048 Jan 22 15:26 857263
drwxrwx--- 4 user2 taskfmri 2048 Jan 23 16:32 857263?

There are ~50 of these directories with '?' in the ls. Unfortunately, the '?' isn't literally a ?, but is instead some special character that the terminal can't display

What is the best way to remove all of these directories with unknown special characters, without deleting the almost-identically named good directories?

share|improve this question

2 Answers 2

If all your directories have names made of digits and then a special char (neither digit nor letter), you could use

find -maxdepth 1 -type d -regex "./[0-9]*[^0-9a-zA-Z]" -exec rm -r {} \;

share|improve this answer

Can't you just do this?

rm -r 857263?
share|improve this answer

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.