Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Mention shell in which the command lines will be executable
- #!/bin/bash
- if [ $# -ne 1 ]
- then
- #echo command is used to display line of text/string that are passed as an argument
- echo "First check if user is local !! "
- echo "Τrying passwd"
- #trying to find if the user ($ 1) exists in the path: etc/passwd
- #if user is found, then we have to print the 5th item (at line)which is users name
- awk -F: '{print $5}' /etc/passwd | sort -r | grep $1
- else
- echo "Check if user is remote !!"
- echo "Trying getent passwd"
- # first the gatent passwd command looks for the user ($ 1) and then cuts the line #where containing it (with grep command).
- # then the result goes to awk command, to print the 5th item (at line), which is the #users name
- getent passwd |grep $1 |awk -F: '{print $5}'
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement