I have a bash script that is gathering active users on a machine and then I am going to curl away the data. The issue is that the first item in the list won't show up, it is gathering everything after the first. Can anyone explain why?
#!/bin/bash
users=$(ps -eo ruser,rgroup | grep users | sort | uniq | cut -d ' ' -f1)
while read -r users
do
newVar=$newVar$(awk '{print "user_name{name=\""$users"\"}", 1.0}');
done <<< "$users"
Then I curl newVar which should be a concatenation of all users in the format that is required.
awkandreadare both reading from the same standard input.awkreads all of the input on the first iteration, so there's nothing left for thewhileloop to process.whileloop andawk? It seems like you only need one loop.usersinsideawk. It's not the shell variable, since the awk script is in single quotes.