Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search and replace

Status
Not open for further replies.

upilli20001

Technical User
Oct 3, 2005
1
IN
Hi
I have a configuration file as follows

Maxusers 100
LimitConn 500
Unlimiteduse Y

I want to change the values for Maxusers,LimitConn to 10 and comment out Unlimiteduse(add a #) . The file should be like this

Maxusers 10
LimitConn 10
#Unlimiteduse Y .

Please let me know how to write a script for it .

Regards
Upilli
 
man sed or man awk or man ed or ...
What have you tried so far ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
man vi too. Although perhaps it would be better to read some basics on the web first.
 
Hi

Or he could give us some details about his skills. Is possible to be only Unix newby, but knowing Perl, PHP, Ruby or something else from other system, which could be also a good choice for an one-liner.

Feherke.
 
Try...
Code:
awk '$1 ~ /^(Maxusers|LimitConn)$/ {$2 = 10}
     $1 == "Unlimiteduse" {$1 = "#" $1}
     {print}' file1 > file2
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top