hannaman
June 8th, 2010, 10:33 AM
I have a command that gets information on a user account from a database and displays it similar to this format:
U A O Username Profilename Some other text
_ _ _ ________ ___________ _______________
U A O user profile_1 junk.junk.junk
U A O user profile_2 I don't care
Returned number something
I want to feed the profile names to another command that takes a comma separated list of profiles. I am able to get the list, but awk statement:
command | awk '$4 ~ /user/ { print $5 }{ OFS="," }'
I get the list with a trailing comma like:
profile_1,profile_2,
I have been able to remove the trailing comma with sed using:
command | awk '$4 ~ /user/ { print $5 }{ OFS="," }' | sed 's/,*$//'
Even though this works, sed complains of a "missing newline at end of standard input".
I have tried to remove the trailing comma with awk using either sub or gensub, but I have been unsuccessful.
Does anyone know of a cleaner way of getting a comma separated list without the trailing comma like this?
Thanks
U A O Username Profilename Some other text
_ _ _ ________ ___________ _______________
U A O user profile_1 junk.junk.junk
U A O user profile_2 I don't care
Returned number something
I want to feed the profile names to another command that takes a comma separated list of profiles. I am able to get the list, but awk statement:
command | awk '$4 ~ /user/ { print $5 }{ OFS="," }'
I get the list with a trailing comma like:
profile_1,profile_2,
I have been able to remove the trailing comma with sed using:
command | awk '$4 ~ /user/ { print $5 }{ OFS="," }' | sed 's/,*$//'
Even though this works, sed complains of a "missing newline at end of standard input".
I have tried to remove the trailing comma with awk using either sub or gensub, but I have been unsuccessful.
Does anyone know of a cleaner way of getting a comma separated list without the trailing comma like this?
Thanks