Skip to content

Instantly share code, notes, and snippets.

@briantissue
Created March 26, 2015 13:16
Show Gist options
  • Save briantissue/55151baf5adad45fd6d2 to your computer and use it in GitHub Desktop.
Save briantissue/55151baf5adad45fd6d2 to your computer and use it in GitHub Desktop.
Find Users W/User Input
#!/bin/bash
read -p "Enter UserID: " userid
touch find-$userid.txt
for HOST in `cat ../server_list|grep -v ^#`; do echo ${HOST}; ssh ${HOST} "hostname;cat /etc/passwd | grep -i $userid"; echo ""; done >> find-$
for HOST in `cat ../server_list2|grep -v ^#`; do echo ${HOST}; ssh ${HOST} "hostname;cat /etc/passwd |grep -i $userid"; echo ""; done >$
read -p "Press [Enter] key to view the number of servers $userid resides..."
cat find-$userid.txt | grep -i $userid | wc -l
read -p "End of script..."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment