comment and Uncomment single task out of multiple task


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting comment and Uncomment single task out of multiple task
# 1  
Old 06-18-2008
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
# 2  
Old 06-18-2008
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.

Quote:
Originally Posted by 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
# 3  
Old 06-18-2008
My intention is that what is the command if I run it will comment and uncomment the line
# 4  
Old 06-18-2008
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.
# 5  
Old 06-18-2008
If you want to comment the "TASK gsnmpproxy" you can something like:

Code:
awk '/TASK gsnmpproxy/{f=1} f{$0="#"$0} /\}/&&f{f=0} 1' file

Regards
# 6  
Old 06-18-2008
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
# 7  
Old 06-18-2008
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. Shell Programming and Scripting

need a script that does a simple task on multiple unix servers.

hi guys, i need a script that does a simple task on multiple aix servers. if possible with both telnet and ssh. the simple task i wanna do is connect to a server and run "ifconfig -a" and get the output. nextweek i need to do similar jobs on like 50 servers... :( can anybody help me with making... (2 Replies)
Discussion started by: curtis911
2 Replies

4. 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

5. Shell Programming and Scripting

Task

Hi experts, I have a problem with the below shell task: I need to modify the file creatin a paired row , per each row which matches filter (e.g. number of nonempty columns = 5) Output should look like this: second row is original one from the input, first row(red) is pairing row, it's... (29 Replies)
Discussion started by: hernand
29 Replies

6. Shell Programming and Scripting

task

Hi all, I'm newbie and stuck here. Thanks for any help. Input(txt file) a b X c d Y e f Z g h W Requested output: a b X Y c d Y X e f Z W g h W Z Please use code tags when posting data and code samples! (10 Replies)
Discussion started by: hernand
10 Replies

7. Shell Programming and Scripting

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 ... (2 Replies)
Discussion started by: jcdole
2 Replies

8. 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

9. 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

10. Shell Programming and Scripting

Parse an XML task list to create each task.xml file

I have an task definition listing xml file that contains a list of tasks such as <TASKLIST <TASK definition="Completion date" id="Taskname1" Some other <CODE name="Code12" <Parameter pname="Dog" input="5.6" units="feet" etc /Parameter> <Parameter... (3 Replies)
Discussion started by: MissI
3 Replies
Login or Register to Ask a Question