diff options
| author | mo khan <mo.khan@gmail.com> | 2019-10-14 09:53:56 -0600 |
|---|---|---|
| committer | mo khan <mo.khan@gmail.com> | 2019-10-14 09:53:56 -0600 |
| commit | 64397c35fb21db7d47d0182eeaa44c2070fc6afa (patch) | |
| tree | a640862b44042076dcc18095cee9792c425785fc /bin/duplicate-ids | |
| parent | 9c63abb0a154c526a480ec8b82672e3252e3f4c3 (diff) | |
Add unit tests
Diffstat (limited to 'bin/duplicate-ids')
| -rwxr-xr-x | bin/duplicate-ids | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/bin/duplicate-ids b/bin/duplicate-ids index 2d04668..a1e2b39 100755 --- a/bin/duplicate-ids +++ b/bin/duplicate-ids @@ -1,3 +1,15 @@ #!/bin/bash -cat /etc/passwd | grep -v -E '^#' | awk -F: '{ print $3 }' | sort -n | uniq -d +FILE=${1:-'/etc/passwd'} + +ids=$(grep -v -E '^#' "$FILE" | awk -F: '{ print $3 }' | sort -n | uniq -d) + +for id in $ids; do + grep -v -E '^#' "$FILE" | awk -F: '{ print $3 " " $1 }' | grep -E "^$id " +done + +if [ -z "$ids" ]; then + exit 0 +else + exit 1 +fi |
