I need to add Centrify/AD accounts to local root groups, which is why I need to manually edit /etc/group as the AD accounts are not recognized via adding the "proper" way, across all of our servers comprised of Linux and AIX. I have the Linux portion working:
LGRP=`grep wheel /etc/group`
ACCT="cycoprts"
sed -i "s/${LGRP}/&,${ACCT}/" /etc/group
sed -i "s/${LGRP}/&${ACCT}/" /etc/group
The first command adds in a comma if there is an existing entry in /etc/group, the second command skips the comma if there are no other users added to the group.
When I test the same command in AIX (without the -i since it's AIX), I get the following (I'm not actually testing with /etc/group, using /etc/test on my end as a "dummy" test file):
AGRP=`grep w3b3root /etc/group`
ACCT1="cycorpad"
root@xxxxxxxxxxx:/etc$ sed "s/${AGRP}/&${ACCT1}/" /etc/group
sed: 0602-404 Function /w3b3root:!:16:/&cycorpad/ cannot be parsed**
Any ideas?
/s
at the start, which I presume should bes/
(unless you've made a typo transferring the command to your post).sed
command. Did you meansed "s/${AGRP}/&${ACCT1}/" /etc/group
? Maybe useset -x
to see the commands that actually get executed. Just in case: Please copy&paste the exact command you used on your system. You might introduce or remove errors when you re-type it here.