admin管理员组文章数量:1420078
I am trying to loop through all sites on a multisite network, and for each site, delete all subscriber users. I have tried this WP-CLI command:
wp site list --field=url | xargs -n 1 -I ^ wp user list --url=^ --role=subscriber --field=ID | xargs -n 2 -I % ^ wp user delete % --url=^ --reassign=4
I can't find a way to pass the ^
value to the second xargs command. Anyone?
I am trying to loop through all sites on a multisite network, and for each site, delete all subscriber users. I have tried this WP-CLI command:
wp site list --field=url | xargs -n 1 -I ^ wp user list --url=^ --role=subscriber --field=ID | xargs -n 2 -I % ^ wp user delete % --url=^ --reassign=4
I can't find a way to pass the ^
value to the second xargs command. Anyone?
- 1 that's a lot of piped/chained commands, does it have to be a one liner with pipes? Couldn't you use a bash variable or two? – Tom J Nowell ♦ Commented Jul 9, 2019 at 14:48
1 Answer
Reset to default 3xargs is unnecessary, something similar to this will do the job without any piping or xargs
:
sites=$(wp site list --field=url)
for site in $sites
do
users=$(wp user list --url="$site" --role=subscriber)
for user in $users
do
wp user delete $user --url="$site" --reassign=4
end
end
本文标签: multisiteHow to run nested xargs commands
版权声明:本文标题:multisite - How to run nested xargs commands? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745323433a2653483.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论