Hello.
I want comment or uncomment a ligne in a config file.
The file name : /etc/samba/smb.conf
Normaly the ligne is uncomment :
so the line begin with a tab character
followed by passdb backend =\tpassdb backend =
In that case I should comment this line and then the line :
begin with #
followed by a tab character \t
followed by passdb backend =#\tpassdb backend =
When I have finish my test then I want to uncomment this line which return in its initial state.
\tpassdb backend =
This line should be in any position in the file.
#!/usr/bin/sh
#
CMD="$1"
FLAG1="# passdb backend ="
FLAG2=" passdb backend ="
F_NAME="/etc/samba/smb.conf"
case "$CMD" in
"uncmt")
sed search "$FLAG1" replace by "$FLAG2" in file $F_NAME
exit
;;
"cmt")
sed search "$FLAG2" replace by "$FLAG1" in $F_NAME
exit
;;
*)
echo "Usage: comment_uncomment_smb-conf {uncmt|cmt}"
exit
esac
echo "done"
Thank you for your time
jcd