#/bin/bash # Run this script to create a fresh copy of .bashrc in the home directory in all users if $HOME/.bashrc has gone missing for some reasons. It will do nothing if $HOME/.bashrc remains intact. users=$(cat /etc/passwd | awk -F":" '{print $1, $3}' | awk '{if($2>=1000 && $2<4000) {print}}' | sort | awk '{print $1}') echo 'users:' $users ####### define your command here for j in $(cat /etc/passwd | awk -F":" '{print $1, $3}' | awk '{if($2>=1000 && $2<4000) {print}}' | sort | awk '{print $1}') do if [ -e /home/"$j"/.bash_profile ]; then echo "/home/$j/.bash_profile exists" ls -la /home/$j/.bash* else echo "/home/$j/.bash_profile does not exist. Will replace them with that kept in /etc/skel/.bash_*" cp -v /etc/skel/.bash_* /home/$j/ chown $j:users /home/$j/.bash* fi done