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 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
Jump to PostI'd rather use the id(1) command :
if id -u $1 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.