Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

bash if user exists in a group then add

egrep -i "^groupname" /etc/group;
if [ $? -eq 0 ]; then
   echo "Group Exists"
else
   echo "Group does not exist -- Invalid Group name"
fi
Comment

bash if user exists in a group then add

egrep -i "^useraccount:" /etc/passwd;
if [ $? -eq 0 ]; then
   echo "User Exists"
else
   echo "User does not exist -- Invalid Username"
fi
Comment

bash if user exists in a group then add

#!/bin/bash
# init
USERID="$1"
#....
/bin/egrep  -i "^${USERID}:" /etc/passwd
if [ $? -eq 0 ]; then
   echo "User $USERID exists in /etc/passwd"
else 
   echo "User $USERID does not exists in /etc/passwd"
fi
# ....
Comment

PREVIOUS NEXT
Code Example
Shell :: ppa user or team does not exist 
Shell :: bash get first number from string 
Shell :: nano edit a file 
Shell :: git pull pr 
Shell :: checkout git 
Shell :: resize all images in folder linux 
Shell :: programming tools fedora 
Shell :: git link on local project 
Shell :: vnc share single window 
Shell :: switch user in ubuntu lxde 
Shell :: NGINX: connect() to unix:/var/run/php7.2-fpm.sock failed (2: No such file or directory) 
Shell :: ubuntu increase volume 
Shell :: update plasma to 5.25 
Shell :: bash force exit 0 
Shell :: docker ps grep container id 
Shell :: how to undo commit 
Shell :: docker-compose: error while loading shared libraries: libz.so.1 
Shell :: create-new-github-repo 
Shell :: turn on wiregurad linux 
Shell :: how to calculate nearest location using longitude and latitude 
Shell :: How to undo the most recent local commits in Git 
Shell :: how to add and commit all files in git 
Shell :: how to open windows powershell 
Shell :: reset branch to other branch 
Shell :: create user in linux 
Shell :: tar gzip compression level 
Shell :: where does redis store data 
Shell :: npm audit undu 
Shell :: installing android studio on kali linux 
Shell :: flutter live reload chrome 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =