Suppose I want to replace a value in a file only once. My command is replacing it for all the matchin pattern. example
read -p "Enter the reference account name : " ACC
read -p "Enter the user name to be inserted into VISUDO : " UNAME
sed -i "s/\( *$ACC =*\)[^ ]*\(.*\)*$/\1 $UNAME,\2/" sudo_file.txt
File is
User_Alias USERS1 = user1
Runas_Alias APP = oozie
Cmnd_Alias SU_APP = /bin/su - oozie
USERS1 ALL = (root) SU_APP
USERS1 ALL = (APP) ALL
when m running its replacing all the values USER1 in the above file. I want the output as
User_Alias USERS1 = user1, user2, user3
Only for this line and not for other two USER1
appearing in the file.
Where ACC is USER1 and UNAME is "user1" or "user2" or "user3" etc