Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- # script input should be (sh groupsum.sh /etc/passwd)
- if [ -f $1 ] ; then
- awk -F ':' '{print $4}' $1 > /tmp/numb
- A=`awk '{s+=$1} END {print s}' /tmp/numb`
- echo $A
- else
- echo "its not a file"
- fi
- #!/bin/bash
- [[ -f "$1" ]] || { echo "Not a file" >&2; exit 1; }
- exec <"$1"
- total=0
- while IFS=':' read -r _ _ _ groupid _; do
- (( total += groupid ))
- done
- echo "$total"
- $ yourscript <(getent passwd)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement