Markus, On Monday 06 June 2005 07:04, Markus Natter wrote:
On 6/6/05, Randall R Schulz
wrote: ...
Put this in a file, make it executable and put the file in a directory in your PATH. Call it "di", perhaps?
-==--==--==--==--==--==--==--==--==--==--==--==--==--==--==- #!/bin/bash --norc
getent passwd uid "$@" |sed -e 's/:.*//' -==--==--==--==--==--==--==--==--==--==--==--==--==--==--==-
The down-side is that you get no output and no diagnostic for unknown ID. Fixing that can be an "exercise for the reader."
Andreas
Randall Schulz
thanks,
something like this should do it then, if the ID is unknown..
-- snip -- #!/bin/bash
res=$(getent passwd uid "$@" |sed -e 's/:.*//') if [ "$res" == "" ]; then echo "unknown user id" exit 2
fi -- snap --
Not really. There are two problems: 1) That will only give the diagnostic when none of the IDs passed are found by getent. 2) It produces only diagnostic output. Try this: -==--==--==--==--==--==--==--==--==--==--==--==--==--==--==- #!/bin/bash --norc for id; do pwEnt="$(getent passwd uid "$id")" if [ ! "$pwEnt" ]; then echo "di: User id $id unknown" >&2 else echo "$id: ${pwEnt%%:*}" fi done -==--==--==--==--==--==--==--==--==--==--==--==--==--==--==-
markus
Randall Schulz