First you have to handle the header specially (want it in the result but not in the comparisons).
In order to compare by uid you need numeric uids (-n), but that means you can't also get the readable username, so you need a custom output format.
Then you need to ensure the output format is such that nothing with possible spaces or control chars can end up in a column before the data you're looking at, as then finding the right column is hard.
Even then, extracting the first command line arg like in the example will fail in the case of a binary name that has a space in it (as there is no way to know which spaces in the commandline corresponds to actual spaces in the arguments or just delimiters).
First you have to handle the header specially (want it in the result but not in the comparisons).
In order to compare by uid you need numeric uids (-n), but that means you can't also get the readable username, so you need a custom output format.
Then you need to ensure the output format is such that nothing with possible spaces or control chars can end up in a column before the data you're looking at, as then finding the right column is hard.
Even then, extracting the first command line arg like in the example will fail in the case of a binary name that has a space in it (as there is no way to know which spaces in the commandline corresponds to actual spaces in the arguments or just delimiters).