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 08:42 AM
How to change the file name rp1982 UNIX for Dummies Questions & Answers 2 11-29-2007 08:49 PM
Change format to file II DebianJ UNIX for Advanced & Expert Users 0 03-07-2006 10:25 AM
How to change this file with SED? bejgirl Shell Programming and Scripting 4 01-03-2006 05: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 Display Modes
  #1 (permalink)  
Old 03-06-2006
Registered User
 

Join Date: Feb 2006
Location: JP.Tokyo
Posts: 30
Stumble this Post!
Help to change value from a file.

How can I change the value of "INI_TEST" from "YES" to "NO" in the setup.ini file by command?

[galaxy@test01 test]$ cat setup.ini
INI_START YES
INI_END YES
INI_TEST YES

Thank u in advance!
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 03-06-2006
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,660
Stumble this Post!
If it just one occurrence, then manual changing to NO will help.

Else,
Code:
sed -e 's/\(INI_TEST\) YES/\1 NO/g' setup.ini > setup.ini.new
Of if you have a -i option for your sed,
Code:
sed -i -e 's/\(INI_TEST\) YES/\1 NO/g' setup.ini
Reply With Quote
  #3 (permalink)  
Old 03-06-2006
Registered User
 

Join Date: Jan 2006
Posts: 125
Stumble this Post!
Code:
sed 's/INI_TEST YES/INI_TEST NO/g' text > text
#substitute INI_TEST YES with INI_TEST NO and overwrite the original file
the above command will fail. it seems that the original file will become empty. Can someone explain?
Reply With Quote
  #4 (permalink)  
Old 03-06-2006
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,660
Stumble this Post!
Quote:
Originally Posted by new2ss
Code:
sed 's/INI_TEST YES/INI_TEST NO/g' text > text
#substitute INI_TEST YES with INI_TEST NO and overwrite the original file
the above command will fail. it seems that the original file will become empty. Can someone explain?
Redirect the output to some other file and then rename it later. Else the read-write operations are being carried out on a single file.
Like I mentioned before, if you have a -i option for your sed, use that for operations like read and write on a single file.
Reply With Quote
  #5 (permalink)  
Old 03-06-2006
Registered User
 

Join Date: Jan 2006
Posts: 125
Stumble this Post!
Thanks vino!
Reply With Quote
  #6 (permalink)  
Old 03-06-2006
Registered User
 

Join Date: Feb 2006
Location: JP.Tokyo
Posts: 30
Stumble this Post!
It seems that I can't change the value straightly ......
Is there any method to change the value straightly? ( not use sed )
Reply With Quote
  #7 (permalink)  
Old 03-06-2006
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,660
Stumble this Post!
Quote:
Originally Posted by GCTEII
It seems that I can't change the value straightly ......
Is there any method to change the value straightly? ( not use sed )
Why cant you change the value manually ? What is it that you are trying and what is the error that you are facing ? Check the permissions et al..

I think it should be as simple as opening the file in your favourite editor and changing the value.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 02:30 AM.


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

Content Relevant URLs by vBSEO 3.2.0