syntax error, need to redo one line in script :(

I have a script that processes a file with two columns (IDs and Idle session times):

# cat /tmp/idle-ids.lst
user1 2,390
user2 97
user3 93
user4 67
user5 56
user6 33
user7 22
user8 6
user9 2
user10 0

my script works, but has a syntax error :frowning:

the following statements contain the syntax error...believe it's the awk line:

awk '{print $1, $2}' /tmp/idle-ids.lst | while read var1 var2
do
if [ $var2 -ge 15 ]
then
echo "$var1 $var2 mins." >> /tmp/idle.msg
fi

is there a better/correct way to redo this awk/while line?

any assistance would be appreciated,
manny

You have a syntax error because of the 2,390 value which is not an integer.
You can change your awk command by using cat, of writing a full-awk script.

Here is a simpler way:

awk '$2 >= 15 { printf("%s %d mins\n", $1, $2) }' /tmp/idle-ids.lst > /tmp/idle.msg

You can try this:

cat /tmp/idle-ids.lst | while read var1 var2
do
var2=$(echo $var2 | cut -d, -f1)
if [ $var2 -ge 15 ]
then
     echo "$var1 $var2 mins."
fi

Output:

user2 97 mins.
user3 93 mins.
user4 67 mins.
user5 56 mins.
user6 33 mins.
user7 22 mins.

thanks guys!!!
syntax free is always a good thing :smiley: