I'm writing a script to add new users to an OS X system on the command line. I know I can list all users on a system with their user IDs using:
dscl . -list /Users UniqueID
which gives something like:
xxxxxxx 937
xxxxxxxx 939
xxxxx 940
xxxxxx 941
How can I retrieve the greatest user ID from this output to store in a variable?
This will give you the line with the highest ID:
dscl . -list /Users UniqueID | sort -nr -k 2 | head -1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With