![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
| Please help to modify my script | Renjesh | Shell Programming and Scripting | 6 | 05-21-2008 08:08 AM |
| modify and use awk sed program | mnnarendra | Shell Programming and Scripting | 3 | 03-26-2008 01:08 PM |
| Checking for future / non existent dates | DKNUCKLES | Shell Programming and Scripting | 2 | 10-09-2007 06:20 AM |
| Modify FTP script to have SCP | madhunk | Shell Programming and Scripting | 2 | 04-26-2006 03:35 PM |
| Modify A Program | tullo | UNIX for Advanced & Expert Users | 4 | 08-18-2003 04:12 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
add or modify if existent
I want to set these params in /etc/system
set shmsys:shminfo_shmmax=2000000000 set shmseg:shminfo_shmseg=200 if this param exists, then I want to modify them if not, I want to add them. I can add them using >>/etc/system but how to do the modify thing? at least I can comment the existing lines -if existent- and then add the 2 entries. |
|
||||
|
Code:
awk -F"[ =]" '
BEGIN { arr["shmsys:shminfo_shmmax"]="set shmsys:shminfo_shmmax= 2000000000";
arr["shmseg:shminfo_shmseg"]="set shmseg:shminfo_shmseg=200"; }
{ if( arr[$2] !~ /^ *$/ ) { print arr[$2]; delete arr[$2]; }
else print }
END {
for( key in arr ) {
if( arr[key] !~ /^ *$/ ) { print arr[key] }
} } ' /etc/system > tmp
mv tmp /etc/system
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|