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
Use a # at starting of line which is to commented with in the script.
e.g.
#!/bin/bash
# mycommand
command1
in this script the command line mycommand will not get executed...
and to uncommant remove # from there.
madhusmita:
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
My intention is that what is the command if I run it will comment and uncomment the line
or Please suggest if the file contains a line snmpd so how to comment and uncomment the snmpd in the file by running the in the command prompt in shell.
If you want to comment the "TASK gsnmpproxy" you can something like:
awk '/TASK gsnmpproxy/{f=1} f{$0="#"$0} /\}/&&f{f=0} 1' file
Regards
you can use....
suppose test is the file name and you want to comment line having gsnmpproxy
grep gsnmpproxy test| sed -ie 's/ ^/#/g'
Thanks-
Yogi
When I run this command from other server through ssh ...ssh is workinf fine..here X,Y,Z is used for ssh
${X} -l ${Y} ${Z} "trap '' INT;. ~/.profile >/dev/null 2>/dev/null; awk '/TASK gsnmpproxy/{f=1} f{$0="#"$0} /\}/&&f{f=0} 1' filename"
it gives error like
awk: syntax error near line 1
awk: bailing out near line 1
So please suggest above one or please write how to comment a line in a file if the that line is INDIA.
is there possible by perl script ??
Pls provide it
Useless use of grep, sed can grep for you.
@madhusmita
man sed to see if your sed support -i switch
sed -i '/TASK gsnmpproxy/s/^/#/' test
madhusmita:
When I run this command from other server through ssh ...ssh is workinf fine..here X,Y,Z is used for ssh
${X} -l ${Y} ${Z} "trap '' INT;. ~/.profile >/dev/null 2>/dev/null; awk '/TASK gsnmpproxy/{f=1} f{$0="#"$0} /\}/&&f{f=0} 1' filename"
it gives error like
awk: syntax error near line 1
awk: bailing out near line 1
So please suggest above one or please write how to comment a line in a file if the that line is INDIA.
Use nawk or /usr/xpg4/bin/awk on Solaris.