May 29, 2009 17:12
How can I haz output from command line application in shell variable? I'm writing a shell script that needs to know a users uid number. So I've tried UID=id -u $NAME and what I think might be every possible combination of grouping symbols, and none of them work. What the hell? The output is a SINGLE NUMBER. It should not be this hard to store it and use it in a shell script. I've even tried set, but it seems ultimately useless (in general, actually).
EDIT: While by no means hard to come up with, this solution feels so kludgey it's almost painful: id -u $NAME | awk '{'UID'=$0}' awk to the rescue, I guess.