I need to edit the sudo file on lots of machines. I figure the easiest way is to run a for loop to ssh to each box, sed the sudoers file to a new file & copy/move back over the top of the original (and of course, change permissions accordingly)
The problem is, I'm not sure how to add a line after a match with sed.
So if my file looks like:
Code:
# comments
root ALL=(ALL) ALL
briank ALL=(ALL) ALL
other ALL=(ALL) ALL
# more comments
I'd like it to add the new sudoer after "other" so the file looks like:
Code:
# comments
root ALL=(ALL) ALL
briank ALL=(ALL) ALL
other ALL=(ALL) ALL
newguy ALL=(ALL) ALL
# more comments
I'm open to other solutions if this doesn't seem reasonable (other solutions that result in one new user having sudo privs - not everyone in a group or something like that.
)