etcdctl recursive delete with wildcards

Created on 26 Feb 2015  路  12Comments  路  Source: etcd-io/etcd

There are times where is would be very useful to recursively delete based on wildcard.

e.g. rm -rf /foo/bar/*

Help Wanted areperformance

Most helpful comment

For etcd v3 use etcdctl del --prefix=true <prefix>

That will delete everything starting with <prefix>

All 12 comments

We have remove recursively functonality:

unihorn@CoreOS ~/g/s/g/c/etcd> ./bin/etcdctl --no-sync rm --help
   rm - remove a key

USAGE:
   command rm [command options] [arguments...]

OPTIONS:
   --dir        removes the key if it is an empty directory or a key-value pair
   --recursive      removes the key and all child keys(if it is a directory)
   --with-value     previous value
   --with-index '0' previous index

what about the wild-cards?

--recursive removes the key and all child keys(if it is a directory)

@timothysc What you want here is the ability to do this:

Give the following keys:

/foo/bar/a
/foo/bar/b
/foo/bar/dir/a
/foo/bar/dir/b

After running the following command:

rm -rf /foo/bar/*

You want the following keys to exist:

/foo/bar/dir/a
/foo/bar/dir/b

Does that look right?

@kelseyhightower yup.

I ended up here looking exactly for what's requested. I ended up doing a etcdctl ls -recursive, greping for the keys I wanted to remove and feeding them to etcdctl rm

@olibob great minds think alike ;-)

Anyway... I know upstream is not to keen on treating it as a file-system, but users would ideally like to perform all the traditional ops. IMHO a fuse mount would enable, and folks could just say they _will not_ support the entirety of POSIX semantics.

Then I could just perform traditional shell commands and be done with it vs. trying to force fit through etcdctl

Sounds like I'm not the only one that wants etcdctl to become a full-fledged etcd CLI client...

:+1:

Just chanced across this, but wouldn't the shell fill in the * before passing it into etcdctl?

I am inclined to close this. We do not actively working on v2 anymore. v3 does not support the concept of dir, so this is not an issue anymore.

sgtm

For etcd v3 use etcdctl del --prefix=true <prefix>

That will delete everything starting with <prefix>

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  路  3Comments

ramanala picture ramanala  路  4Comments

suresh-chaudhari picture suresh-chaudhari  路  3Comments

itnikita picture itnikita  路  3Comments

r007m4n picture r007m4n  路  3Comments