Advertisement
Guest User

Untitled

a guest
Sep 27th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. IN=${1:-/etc/passwd}
  4.  
  5. sort -r -k3 -t: -n $IN | # Ordenamos por UID (reverso)
  6. # ALTERNATIVA 1
  7. cut -f1-3 -d: | # Nos quedamos con los campos user:pass:UID
  8. sed 's/\(.*\):.*:\(.*\)/\1 \2/g' | # Eliminamos el campo pass
  9. # ALTERNATIVA 2
  10. # cut -f1,3 -d: | #Nos quedamos con los campos user:UID
  11. # tr ':' ' ' | # Cambiamos el ':' por ' '
  12. # ALTERNATIVA 3
  13. # cut -f1,3 -d: --output-delimiter=' ' | #Nos quedamos con los campos 'user UID'
  14. uniq -f1 -c -d | # Obtenemos el numero de duplicados
  15. sed 's/\(.*\) \(.*\) \(.*\)/\2 \1/' | # Formato <user> <repeticiones>
  16. tr -s ' ' | # Comprimimos espacios
  17. tac # Ordenamos de menor a mayor UID
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement