Xargs (Bash)

Uit De Vliegende Brigade
Naar navigatie springen Naar zoeken springen

xargs is an explicit way of reusing the output of a command. I often use it, when more implicit ways of pipelining like through > or | doesn't work, like with WP-CLI:

Examples WP-CLI

# Remove orders
########################################
#
wp wc shop_order list --user=4 --field=id --per_page=100 --offset=$(($i*100))  | xargs -n1 wp wc shop_order delete --user=4 --force=1


# Remove tax rules
########################################
#
wp --user=4 wc tax list --field=id | xargs -n1 wp --user=4 wc tax delete --force=true


# Process a sequence of numbers
########################################
#
seq $post_start $post_end | xargs wp media regenerate --only-missing --yes

See also