How to parse mysql query output as variable into another command in linux via Drush? Currently I'm doing a mysql query via the command line using Drush and I want to parse the query output and grab the Node ID #, then put that ID # into a drush php-cli 'node_delete(X)' command. How can I do this? Currently I have the command:

drush sql-query 'select * from node where type="feed_item" AND status=0 limit 1 \G'

then

drush php-eval 'node_delete(X)'


I think I'm suppose to use the command xargs?

From there how can I make this as a loop and delete everything that get's outputted? Yes I know I can just do it via the site, but i want to know how to do it via the command line using only Drush. Eventually I just want to make an interactive bash script where I can just put in the node ID range numbers and it will just delete it at once.
Based on the query that you've provided, you're just getting one unpublished feed_item, then deleting it. This can be done in one line, without an intermediate bash step.

drush ev "node_delete(
  db_select('node')
    -&gt;fields('node', array('nid'))
    -&gt;condition('status', '0', '=')
    -&gt;condition('type', 'feed_item', '=')
    -&gt;range(0, 1)
    -&gt;execute()
    -&gt;fetchField()
);"


If you wanted to delete multiple nodes at once - or all nodes returned with your conditions, then use https://api.drupal.org/api/drupal/modules%21node%21node.module/function/node_delete_multiple/7 , remove the range and use fetchCol() to return an array of NIDs.

drush ev "node_delete_multiple(
  db_select('node')
    -&gt;fields('node', array('nid'))
    -&gt;condition('status', '0', '=')
    -&gt;condition('type', 'feed_item', '=')
    -&gt;execute()
    -&gt;fetchCol()
);"