Sponsored Content
Top Forums Shell Programming and Scripting uncomment or comment one specific line in a config file Post 302514711 by jcdole on Sunday 17th of April 2011 06:18:03 PM
Old 04-17-2011
uncomment or comment one specific line in a config file

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
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need to add a comment line in a text file

Hi I need to add a comment line at the begining of a text file. The scenario is given below. 1. The number of servers that needs to be updated is around 80 2. The location of the text file in all the servers are the same including the file name. 3. The comment has to be added at the very... (2 Replies)
Discussion started by: orakhan
2 Replies

2. Shell Programming and Scripting

comment and Uncomment single task out of multiple task

I have a file contains TASK gsnmpproxy { CommandLine = $SMCHOME/bin/gsnmpProxy.exe } TASK gsnmpdbgui { CommandLine = $SMCHOME/bin/gsnmpdbgui.exe I would like to comment and than uncomment specific task eg TASK gsnmpproxy Pls suggest how to do in shell script (9 Replies)
Discussion started by: madhusmita
9 Replies

3. Shell Programming and Scripting

Comment/uncomment a cron

Hi, My requirement is to comment/uncomment a cron job through a script. 1. Redirected the output of crontab -l to a text file. crontab -l >cronoutput.txt 2. grep to find the script running and sed to place the comment (#) as the first char grep -i 'weblogicmonitor.sh'... (5 Replies)
Discussion started by: mannepalli
5 Replies

4. Shell Programming and Scripting

comment and uncomment a line with Shell Script

Requirement is: 1. comment and uncomment the line with Shell Script: /opt/admin/fastpg/bin/fastpg.exe -c -=NET (using fastpg.exe as a search option) 2. display = "Commented" (when its commented) and display = "Uncommented" (when its uncommented) Its urgent, please let me asap!!! Thanks in... (2 Replies)
Discussion started by: anthonyraj75
2 Replies

5. Shell Programming and Scripting

comment/uncomment grep output

Hi I need help to comment/uncomment the output from grep command output within a file from command line using shell script. # grep -i -p testfs filesystem.out /TestFs: dev = /dev/TestFslv vfs = jfs2 log = /dev/hd8 mount ... (2 Replies)
Discussion started by: mbak
2 Replies

6. UNIX for Dummies Questions & Answers

Easiest way to comment/uncomment a shell script?

cd path line1 line2 line3 line4 line5 Lets say thats the sample script...So say if i have to comment the above script, which would be the better way so that whenever i want, i cud comment or uncomment the same. Thanks (1 Reply)
Discussion started by: saggiboy10
1 Replies

7. Shell Programming and Scripting

To comment/uncomment in config file

hi! I want to comment and uncomment 2 lines in my config files that goes like: CONTACT_LIST="abc@xyz.com;" #CONTACT_LIST="def@xyz.com;" I want to sawp the commnets in above lines and desired output should be: #CONTACT_LIST="abc@xyz.com;" CONTACT_LIST="def@xyz.com;" Please suggest. (1 Reply)
Discussion started by: scriptNovice
1 Replies

8. Shell Programming and Scripting

Perl uncomment line

Hi guys I am making a bash script, need to un-comment a line remove the"#" Want to accomplish this with a Perl command. Line is like this: #readclients = yes Need it like this: readclients = yes Any help would be really appreciated. (3 Replies)
Discussion started by: Tox
3 Replies

9. Shell Programming and Scripting

How to comment a specific line of a file?

Hi, I need to comment out (insert # in the front of a line) a line that has entry Defaults requiretty using command-line as I need to do this on hundreds of servers. From Defaults requiretty To #Defaults requiretty I tried something like below but no luck: Please advise,... (3 Replies)
Discussion started by: prvnrk
3 Replies

10. UNIX for Beginners Questions & Answers

How to comment a specific line of a file in Solaris 10?

Hi Folks, sed -i '3s/^/#/' abc.txt is commenting the line number 3 in LINUX Not Working in Solaris 10 or higher sed -i sed -i '3s/^/#/' abc.txt sed: illegal option -- i i have a file as below cat abc.txt bc vdv shhsd cdc skdk Please advise (15 Replies)
Discussion started by: abhaydas
15 Replies
IDMAP_ODSAM(8)															    IDMAP_ODSAM(8)

NAME
idmap_odsam - Open Directory ID mapping backend for winbindd SYNOPSIS
The idmap_odsam plugin is the default backend used by Mac OS X for mapping SIDs and user and group IDs using Open Directory. It implements both the "idmap" and "idmap alloc" APIs. idmap_odsam should always be used in conjunction with the odsam passdb backend. IDMAP OPTIONS
odsam: msglevel = LEVEL LEVEL is the integer log level at which idmap_odsam should emit log messages. The lower LEVEL is, the more verbose the log mes- sages. odsam: traceall = BOOL If this is true, idmap_odsam will emit log messages for all Open Directory calls. If it is false (the default), it will only log errors. IDMAP ALLOC OPTIONS
The idmap_odsam does not allocate any mappings. On Mac OS X, all SID mappings should be made by modifying the appropriate Open Directory record. EXAMPLES
[global] idmap domain = default idmap config default:default = yes idmap config default:backend = odsam idmap alloc backend = odsam passdb backend = odsam odsam: msglevel = 0 # Log at debugging levels odsam: traceall = no # Do not trace Open Directory calls BUGS
Please report bugs to Apple. SEE ALSO
DirectoryService(8), smb.conf(5), winbindd(8) IDMAP_ODSAM(8)
All times are GMT -4. The time now is 01:12 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy