Sponsored Content
Top Forums Shell Programming and Scripting Modify existing values in a file Post 302897597 by darling on Tuesday 15th of April 2014 10:39:08 AM
Old 04-15-2014
ok.. Thanks for your swift responce.. Let me tell you what i am trying to do here..

i am trying to edit "sysctl.conf" file.. if this file has got below variables with below values or morethan that then it should leave that value...

If variable value is less than that then it should alter the value to below given value

For example:

sysctl.conf file has below values

Code:
kernel.shmall = 5194304 (more than 4194304 so it should leave it as it is)

kernel.shmmax = 2147483648 (it is equal to 2147483648 so it should leave it as it is)

kernel.msgmni = 124 (it is less than 1024 so it should alter the value to 1024)

expecting output is
Code:
kernel.shmall = 5194304 

kernel.shmmax = 2147483648

kernel.msgmni = 1024

will you able to help me on this to write a script or weather i am going in right direction to achive above output by previously shared script

---------- Post updated at 09:39 AM ---------- Previous update was at 03:49 AM ----------

This is my script i am preparing to replace "kernel.shmall" if value is less than equal 4194303

script:

Code:

#!/bin/sh
echo `cat /emblocal/sysctl.conf|fgrep kernel.shmall`|while read kernel.shmall
if
[ "kernel.shmall" -le 4194303 ];
then
kernel.shmall = 4194304
fi

output of

Code:
cat /emblocal/sysctl.conf|fgrep kernel.shmall

is

Code:
kernel.shmall = 419430 #kernel.shmall = 2097152

it should take only kernel.shmall, not which are commented "#" like #kernel.shmall



can you let me know how to do it?
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

How to modify an existing pdf with unix shell commands

Hi, I know that to create a pdf file I can use the txt2pdf command. But if I would change an existing pdf file, by inserting lines in particular positions of this file, what can I use? And How? (3 Replies)
Discussion started by: fandwick
3 Replies

2. Shell Programming and Scripting

folder existing and file existing

I want to look into a folder to see if there are any folders within it. If there are, I need to check inside each folder to see if it contains a .pdf file So If /myserver/myfolder/ contains a folder AND that folder conatins a .pdf file do X Else do Z I may have multiple folders and... (4 Replies)
Discussion started by: crowman
4 Replies

3. Solaris

Add existing user into an existing group

Pre: no gpasswd/adduser there is just usermod can be used, also there is no -a option for usermod. How should I add a user into a group? (4 Replies)
Discussion started by: a2156z
4 Replies

4. Shell Programming and Scripting

insert pipes for existing and non-existing records

I have a source file like this, L4058S462 34329094 F51010141TK1070000483L4058S462 34329094 0232384840 381892 182 5690 L4058S462 34329094 F51020141FIRST CLEARING, LLC A/C 3432-9094 L4058S462 34329094 F51030141JOHAN HOLMQVIST ... (1 Reply)
Discussion started by: saravanamr
1 Replies

5. Shell Programming and Scripting

modify Existing MS excel workbook in perl

Hi I need to modify an excel file in perl and for which I installed perl in Linux 1. Open a existing excel file 2. delete an unwanted Sheet called "summary" 3. and i want to insert some data into range of cells ( B1:B11) 4. Remove unwanted value called "Sum" repeated in the... (1 Reply)
Discussion started by: luke_devon
1 Replies

6. Shell Programming and Scripting

modify a file by inserting a conditional values

Hi, input file CCCC 1204 215764.85 9405410.40 1189 DDDD 4498 1503 4617 1507 4723 1517 4829 1528 4996 1540 DDDD 5199 1556 5278 1567 5529 1603 5674 1614 6076 1915 DDDD 6605 2371 7004 2779 CCCC ... (4 Replies)
Discussion started by: Indra2011
4 Replies

7. Shell Programming and Scripting

how to modify existing env var

greetings, i have the following env variable: LSB_HOSTS='t70cra102 t70cra102 t70cra108 t70cra108'the variable could be any number of host names and sometimes the same name several times. i was hoping there's a way to turn it into the following: NEW_LSB_HOSTS=,,,]always appreciate the help... (2 Replies)
Discussion started by: crimso
2 Replies

8. Shell Programming and Scripting

Adding columns with values dependent on existing columns

Hello I have a file as below chr1 start ref alt code1 code2 chr1 18884 C CAAAA 2 0 chr1 135419 TATACA T 2 0 chr1 332045 T TTG 0 2 chr1 453838 T TAC 2 0 chr1 567652 T TG 1 0 chr1 602541 ... (2 Replies)
Discussion started by: plumb_r
2 Replies

9. Shell Programming and Scripting

Need to implement new CRON job or modify the existing one in MDM PROD in coming days, which will sen

Need to implement new CRON job or modify the existing one in MDM PROD in coming days, which will send email of SQL statement running from past 1 minute.Currently there is one CRON job in PROD, which send below email. there is one cron job which send email, when there is long running... (0 Replies)
Discussion started by: dampu
0 Replies

10. Shell Programming and Scripting

Pattern search and modify the values

I have one file and the file may contain 500 to 15,000 records. I need to search pattern ^F509= and then increment the corresponding value by one and print the entire line. Please note that Its not a fixed length file. Can anyone please help? ex: ^F509=204656 ^F509=204656 ... (6 Replies)
Discussion started by: vinus
6 Replies
SYSCTL.D(5)							     sysctl.d							       SYSCTL.D(5)

NAME
sysctl.d - Configure kernel parameters at boot SYNOPSIS
/etc/sysctl.d/*.conf /run/sysctl.d/*.conf /usr/lib/sysctl.d/*.conf DESCRIPTION
systemd uses configuration files from the above directories to configure sysctl(8) kernel parameters to load during boot. CONFIGURATION FORMAT
The configuration files should simply contain a list of variable assignments, separated by newlines. Empty lines and lines whose first non-whitespace character is # or ; are ignored. Note that both / and . are accepted as separators in sysctl variable names. Each configuration file is named in the style of <program>.conf. Files in /etc/ overwrite files with the same name in /usr/lib/. Files in /run overwrite files with the same name in /etc/ and /usr/lib/. Packages should install their configuration files in /usr/lib/, files in /etc/ are reserved for the local administration, which possibly decides to overwrite the configurations installed from packages. All files are sorted by filename in alphabetical order, regardless in which of the directories they reside, to ensure that a specific configuration file takes precedence over another file with an alphabetically later name. EXAMPLE
Example 1. /etc/sysctl.d/domain-name.conf example: # Set kernel YP domain name kernel.domainname=example.com SEE ALSO
systemd(1), sysctl(8), sysctl.conf(5) AUTHOR
Lennart Poettering <lennart@poettering.net> Developer systemd 10/07/2013 SYSCTL.D(5)
All times are GMT -4. The time now is 07:23 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy