Etcd: Is there a way to remove empty directories recursively?

Created on 17 Feb 2016  路  5Comments  路  Source: etcd-io/etcd

Is there a way to remove empty directories recursively?

Most helpful comment

If you want to delete recursively you can do etcdctl rm /path/to/dir --recursive.
But if you want to delete only empty ones, you have to do manually.

All 5 comments

Please try etcdctl rmdir command (https://github.com/coreos/etcd/tree/master/etcdctl#deleting-a-key).

rmdir is removes the key if it is an empty directory or a key-value pair

i was thinking of something like lets say

key:                                value:
/path
/path/ta
/path/ta/key                        test
/path/to
/path/to/key                        test
/path/towards                
/path/towards/key                   test

$ etcdctl rm /path/ta/key
$ etcdctl rm /path/to/key
$ etcdctl ls --recursive

/path
/path/ta
/path/to
/path/towards
/path/towards/key

$ etcdctl <somecommand> /path

where <somecommand> will delete both /path/to and /path/ta since these are empty dirs. I'm basically looking for a command to clean up empty folders.

If you want to delete recursively you can do etcdctl rm /path/to/dir --recursive.
But if you want to delete only empty ones, you have to do manually.

Then I have to do manually. I see, thanks!

No problem. Please ask us if you have any questions. Thanks.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cheyang picture cheyang  路  3Comments

invidian picture invidian  路  3Comments

itnikita picture itnikita  路  3Comments

olalonde picture olalonde  路  4Comments

kghost picture kghost  路  4Comments