script to add text in middle of file
I'm looking for a solution to adding text to the middle of the smb.conf file. This is my script so far.
Code:
#!/bin/sh smb.conf file share... [file] valid users = blahblah, blahblah2, blahblah3, (Add New User Here) path = /file create mask = 0755 browesable = no read only = no Thanks in advance. |
sed '/valid users/ s/$/, newuser/' smb.conf
|
#!/bin/sh
echo "Enter username" read NAME useradd -c "$NAME" -m $NAME mkdir /file/$NAME echo $NAME = $NAME >> /etc/samba/smbusers smbpasswd -a $NAME sed '/valid users/ s/$/, $NAME/' /etc/samba/smb.conf ...is the new code. It makes $NAME a valid user of the new directory made. /file is the root directory, and has its own share, is there an easy fix to making $NAME a valid user of /file which is already made? |
Use double-quotes if you want to expand the variable name
Code:
sed -i "/valid users/ s/$/, $NAME/" /etc/samba/smb.conf |
All times are GMT -5. The time now is 07:24 PM. |