Page 1 of 1

Editing the Samba Config file

Posted: Wed Aug 27, 2014 8:20 am
by RDK
Folks....I'm well along the way to getting my Pi basic configuration done. I just installed SAMBA and it seems to be working, ie I can see the USB key share I set up.

What I would like to do is create a cleaned up copy of the smb.conf file. It has lots of comments (#'s and ;'s) which make reading it and debugging painful. I found this script on the web:

Code: Select all

grep -ve ^# -ve ‘^;’ -ve ^$ smb.confcopy> smb.confclean
but when I run it in super user mode, the command does not finish, that is it does return to the normal prompt even after 10+ minutes. CTL-c gets me back to the prompt.

What am I doing wrong? OS is RASPBIAN .

Thanks...RDK

Re: Editing the Samba Config file

Posted: Wed Aug 27, 2014 8:41 am
by RaTTuS
are you running sudo blah or
are you doing
sudo sh
then running the command

the second will work the first will not - the redirection will not happen as you think it will

Re: Editing the Samba Config file

Posted: Wed Aug 27, 2014 9:01 am
by Richard-TX
try this


cat smb.conf | grep -ve ^# -ve \.^\;\. -ve ^$ > outfile

Re: Editing the Samba Config file

Posted: Wed Aug 27, 2014 10:55 am
by jojopi
RDK wrote:grep -ve ^# -ve ‘^;’ -ve ^$ smb.confcopy> smb.confclean
In the recipe that you found, there were obviously supposed to be ASCII single quotes around ^; to protect the semicolon from the shell. Something along the way has converted them into Unicode left- and right- single quotes, which no longer serve the purpose. So you have two commands separated by semicolon:

Code: Select all

grep -ve ^# -ve ‘^;
’ -ve ^$ smb.confcopy> smb.confclean
The first grep is reading from standard input, so it waits for you to press Ctrl+D or Ctrl+C. The second "command" is nonsense.

With the correct quotes (and running in a root shell as RaTTuS explains) the command should work (though it is redundant to give the -v option three times).
Richard-TX wrote:cat smb.conf | grep -ve ^# -ve \.^\;\. -ve ^$ > outfile
You have quoted the semicolon adequately, but what are the \. for? The beginning of line (^) cannot match after ., so your version does not remove ; comments.

Re: Editing the Samba Config file

Posted: Wed Aug 27, 2014 11:12 am
by RDK
Folks....Thanks, I think I understand the comments. The string posed by Richard-TX worked good enough for me. It did not eliminate the ; lines nor the blank lines, but did get rid of the # line comments. I can live with this reduction.

Perhaps later I will try the other suggestions and try to really understand what they are doing.

Again, thanks....RDK

Re: Editing the Samba Config file

Posted: Sat Aug 30, 2014 1:42 pm
by tekim
Greetings,

Does the "testparm" command not achieve a similar result?

testparm > smbclean.conf

or maybe

testparm -v > smbclean.conf
for all the default setting included.

Cheers,