Last active
September 27, 2016 13:49
-
-
Save Skardian/0c1bb6ed17edcc8c76eb3de2e5d37a74 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| IN=${1:-/etc/passwd} | |
| sort -r -k3 -t: -n $IN | # Ordenamos por UID (reverso) | |
| # ALTERNATIVA 1 | |
| cut -f1-3 -d: | # Nos quedamos con los campos user:pass:UID | |
| sed 's/\(.*\):.*:\(.*\)/\1 \2/g' | # Eliminamos el campo pass | |
| # ALTERNATIVA 2 | |
| # cut -f1,3 -d: | #Nos quedamos con los campos user:UID | |
| # tr ':' ' ' | # Cambiamos el ':' por ' ' | |
| # ALTERNATIVA 3 | |
| # cut -f1,3 -d: --output-delimiter=' ' | #Nos quedamos con los campos 'user UID' | |
| uniq -f1 -c -d | # Obtenemos el numero de duplicados | |
| sed 's/\(.*\) \(.*\) \(.*\)/\2 \1/' | # Formato <user> <repeticiones> | |
| tr -s ' ' | # Comprimimos espacios | |
| tac # Ordenamos de menor a mayor UID |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment