title: awk two columns into a bash for loop
body: <p>Please help!</p>
  
  <p>I have a little bit of a time sensitive issue here and so I am turning to Stackoverflow in the hope that I can get a fairly quick reply. I'm not a bash expert, especially when having to think quickly. I am trying to awk in two columns from a user database into an OpenStack API. The database (flat file I created) is really simple. It looks something like this:</p>
  
  <pre><code>| ID | username | True |
  </code></pre>
  
  <p>The database is pretty large so I am trying to loop through this. Here is the command I am trying to run:</p>
  
  <pre><code>for user in $(cat users.txt); do keystone user-role-add --user $user --role blah --tenant $tenant; done
  </code></pre>
  
  <p>This works great assuming users.txt list had a single username on each line.</p>
  
  <p>I need to modify this command to pull the username out of users.txt for $user and also pull the corresponding ID out of users.txt for $tenant</p>
  
  <p><strong>* SOLUTION *</strong></p>
  
  <pre><code>while read line;do
    tenant=$(echo $line|awk '{print $2}')
    user=$(echo $line|awk '{print $4}')
    keystone user-role-add --user $user --role blah --tenant $tenant
  done &lt;users.txt
  </code></pre>
  
  <p>Thanks again!</p>