Take the tour ×  Here's what I have so far:  while read line; do
DB=$(echo $line | cut -f1)         USER=$(echo $line | cut -f2)
PASS=$(echo $line | cut -f3)         echo DB=$DB USER=$USER
PASS=$PASS done < users.txt  And a sample of the input file:
drupal_1    drupal1 tmmjXSWL drupal_2    drupal2 FHiJSYHM
drupal_3    drupal3 b7bFNj06 drupal_4    drupal4 0AaV62EL  And
output from the script:  DB=drupal_1 drupal1 tmmjXSWL
USER=drupal_1 drupal1 tmmjXSWL PASS=drupal_1 drupal1 tmmjXSWL
DB=drupal_2 drupal2 FHiJSYHM USER=drupal_2 drupal2 FHiJSYHM
PASS=drupal_2 drupal2 FHiJSYHM DB=drupal_3 drupal3 b7bFNj06
USER=drupal_3 drupal3 b7bFNj06 PASS=drupal_3 drupal3 b7bFNj06
For some reason, each variable is set to the whole line. When I
use echo users.txt | cut -f1 at the command line, it returns the
token just fine.  share|improve this question add comment  2
Answers  up vote 5 down vote accepted  How about this?  $ awk
'{print "DB="$1"\tUSER="$2"\tPASS="$3}' users.txt DB=drupal_1
USER=drupal1    PASS=tm