31 lines
468 B
Awk
31 lines
468 B
Awk
|
#!/usr/bin/awk -f
|
||
|
|
||
|
# Assign a new uid for users that have uid=0
|
||
|
BEGIN {
|
||
|
FS=":";
|
||
|
max_uid = 0;
|
||
|
i = 0;
|
||
|
}
|
||
|
|
||
|
{
|
||
|
max_uid = ($3 > max_uid ? $3 : max_uid);
|
||
|
if ($3 == "0") {
|
||
|
uid0[i] = $0;
|
||
|
} else {
|
||
|
good[i] = $0;
|
||
|
}
|
||
|
i += 1;
|
||
|
}
|
||
|
|
||
|
END {
|
||
|
for (i in good) {
|
||
|
print good[i];
|
||
|
}
|
||
|
|
||
|
for (i in uid0) {
|
||
|
max_uid += 1;
|
||
|
split(uid0[i], f, ":");
|
||
|
print f[1]":"f[2]":"max_uid":"f[4]":"f[5]":"f[6]":"f[7];
|
||
|
}
|
||
|
}
|