2

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?

3 Answers 3

7

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 {} \;

1

I faced a similar issue, and could not work out how to delete ./?d from CLI.

If you have Vim installed, it comes with a visual browser called netrw.

  1. You can open the directory by using vim ./ (to open current directory)
  2. Use the up and down arrows to place the cursor over the file.
  3. Press D (uppercase d) to delete the file.
  4. Press y to confirm.
0

Can't you just do this?

rm -r 857263?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .