The UNIX and Linux Forums  

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

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Change 'which' file is used JJ07 UNIX for Dummies Questions & Answers 1 01-05-2008 09:42 AM
How to change the file name rp1982 UNIX for Dummies Questions & Answers 2 11-29-2007 09:49 PM
Change format to file II DebianJ UNIX for Advanced & Expert Users 0 03-07-2006 11:25 AM
How to change this file with SED? bejgirl Shell Programming and Scripting 4 01-03-2006 06:23 AM
Help with multiple file rename - change case of part of file name steve7 UNIX for Dummies Questions & Answers 7 06-30-2005 10:41 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #8  
Old 03-06-2006
Registered User
 

Join Date: Feb 2006
Location: JP.Tokyo
Posts: 30
I want to make some scripts to change the System configuration automatically. My server is Redhat Enterprise 3.0, it seems I can't use -i option. But thank u in advance.

Last edited by GCTEII; 03-06-2006 at 11:50 PM.
Reply With Quote
Forum Sponsor
  #9  
Old 03-06-2006
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,698
Did you try the sed command that was posted earler ?

Code:
sed -e 's/\(INI_TEST\) YES/\1 NO/g' setup.ini > setup.ini.new
Reply With Quote
  #10  
Old 03-07-2006
Registered User
 

Join Date: Feb 2006
Location: JP.Tokyo
Posts: 30
Quote:
Originally Posted by vino
Did you try the sed command that was posted earler ?

Code:
sed -e 's/\(INI_TEST\) YES/\1 NO/g' setup.ini > setup.ini.new
YES, it works. I want to confirm if there is any much easier way to do that or not.
Reply With Quote
  #11  
Old 03-07-2006
Ygor's Avatar
Moderator
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,249
Code:
$ cat setup.ini
INI_START YES
INI_END YES
INI_TEST YES

$ awk '$1=="INI_TEST"{$2="NO"}{a[NR]=$0}END{close(FILENAME);for(i=1;i<=NR;i++)print a[i]>FILENAME}' setup.ini

$ cat setup.ini
INI_START YES
INI_END YES
INI_TEST NO
Reply With Quote
  #12  
Old 03-07-2006
Registered User
 

Join Date: Feb 2006
Location: JP.Tokyo
Posts: 30
Talking

Quote:
Originally Posted by Ygor
Code:
$ cat setup.ini
INI_START YES
INI_END YES
INI_TEST YES

$ awk '$1=="INI_TEST"{$2="NO"}{a[NR]=$0}END{close(FILENAME);for(i=1;i<=NR;i++)print a[i]>FILENAME}' setup.ini

$ cat setup.ini
INI_START YES
INI_END YES
INI_TEST NO
It does work, perfect!

Thank u all in advance!
Reply With Quote
  #13  
Old 03-07-2006
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,656
There must be a blue moon tonight! This actually looks more readable in perl!
Code:
$ cat setup.ini
INI_START YES
INI_END YES
INI_TEST YES
$ perl -pi -e 'if ($_ =~ /^INI_START/) {s/YES/NO/}' setup.ini
$ cat setup.ini
INI_START NO
INI_END YES
INI_TEST YES
$
Reply With Quote
  #14  
Old 03-07-2006
Registered User
 

Join Date: Feb 2006
Location: JP.Tokyo
Posts: 30
Quote:
Originally Posted by Perderabo
There must be a blue moon tonight! This actually looks more readable in perl!
Code:
$ cat setup.ini
INI_START YES
INI_END YES
INI_TEST YES
$ perl -pi -e 'if ($_ =~ /^INI_START/) {s/YES/NO/}' setup.ini
$ cat setup.ini
INI_START NO
INI_END YES
INI_TEST YES
$
Thank u Perderabo for giving me another way to do it.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 10:41 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0