Hi
I want to check wether user exist in server or not uisng shell script?
can any one help me regarding this
arunkumarch
0
Newbie Poster
Recommended Answers
Jump to PostThis script will tell you if a user account exists on the system, just pass the user name you want to check as an argument to the script like
user_exists.sh foo
#!/bin/bash cat /etc/passwd | grep ^$1 >/dev/null if [ $? == 0 ]; then echo …
Jump to Posthi,
uuoc (useless use of cat)
uuot (useless use of test)if grep -q ^"$1" /etc/passwd then echo "user $1 exists" else echo "user $1 does not exist" exit 1 fi
All 5 Replies
chris.stout
14
Junior Poster in Training
Watael
4
Junior Poster
chris.stout
commented:
That's very cool, thanks for taking the time to to share the improvement.
+1
arunkumarch
0
Newbie Poster
DoRight
2
Light Poster
CrazyDieter
4
Junior Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.