I am writing a shell script that outputs selected MySql table data as an exercise. Searches using my key words turn up only how to print out an entire MySql table, doing this in a different language and irrelevant questions.
My questions:
1) If possible, how do I reference individual attributes of a certain row from the results (like iterating when through rows with PHP results)?
2) Which of the two ways below, if either, makes the most sense for this purpose? Neither works quite the way I would like at the moment.
MYSQL="mysql -u$db_user -p$db_passwd $db_name -Nbe"
A)
RESULT=`$MYSQL "select * from $table_name where can_auto_check='yes';"`
for UNIQUEID in $RESULT
do
echo "selected: $client $desc "
someFunction $client $anothervariable
done
B)
$MYSQL "select * from $table_name where can_auto_check='yes';" \
| while read client anothervariable;
do
echo "selected: $client $desc "
someFunction $client $anothervariable
done
It is possible I am wording my searches incorrectly; if that is the case, I would appreciate if someone would nudge me in the right direction.
Thank you.
EDIT: possible lead.. something to do with awk '{print $1" "$2 }' maybe. but for every line.
Final format = " mkdir -p /net/$SERVER/$CLIENT/$DESC/someFiles "