| 1 | #!/bin/bash |
| 2 | # allprofs.sh: Print all user profiles. |
| 3 | |
| 4 | # This script written by Heiner Steven, and modified by the document author. |
| 5 | |
| 6 | FILE=.bashrc # File containing user profile, |
| 7 | #+ was ".profile" in original script. |
| 8 | |
| 9 | for home in `awk -F: '{print $6}' /etc/passwd` |
| 10 | do |
| 11 | [ -d "$home" ] || continue # If no home directory, go to next. |
| 12 | [ -r "$home" ] || continue # If not readable, go to next. |
| 13 | (cd $home; [ -e $FILE ] && less $FILE) |
| 14 | done |
| 15 | |
| 16 | # When script terminates, there is no need to 'cd' back to original directory, |
| 17 | #+ because 'cd $home' takes place in a subshell. |
| 18 | |
| 19 | exit 0 |