The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Automated FTP task LowOrderBit IP Networking 36 05-04-2009 03:45 AM
process vs task hana UNIX for Dummies Questions & Answers 2 07-02-2006 06:32 PM
cron task not working cassj Shell Programming and Scripting 2 08-05-2004 04:45 PM
difference between task and process ramyar UNIX for Dummies Questions & Answers 6 12-22-2001 08:48 PM
Linux task applet ghoti UNIX for Dummies Questions & Answers 2 12-13-2001 02:10 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-18-2008
madhusmita madhusmita is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 29
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 (permalink)  
Old 06-18-2008
bisla.yogender bisla.yogender is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 30
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 View Post
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 (permalink)  
Old 06-18-2008
madhusmita madhusmita is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 29
My intention is that what is the command if I run it will comment and uncomment the line
  #4 (permalink)  
Old 06-18-2008
madhusmita madhusmita is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 29
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 (permalink)  
Old 06-18-2008
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,212
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 (permalink)  
Old 06-18-2008
bisla.yogender bisla.yogender is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 30
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 (permalink)  
Old 06-18-2008
madhusmita madhusmita is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 29
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.
Sponsored Links
Closed Thread

Bookmarks

Tags
solaris

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 10:17 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0