How to update value in a file using sed linuxAtime value changing only once after file creationHow to put fixed-width, vertically-oriented key-value pairs in a CSV file?How to Prefix a column values with an apostrophe ( ' )?filesystem that works under qemu and I can mount on my hostHow to convert several tiff images into xyz coordinates in a single text file using the terminal?Compare and merge config file in CentOShard vs - in limits.confLinux server deny full accessHow does Linux resolve pathnames with the help of the dentry cache?extract field from file using sed or awk
How to make a pipeline wait for end-of-file or stop after an error?
What are the potential pitfalls when using metals as a currency?
What's the polite way to say "I need to urinate"?
A Strange Latex Symbol
What happened to Captain America in Endgame?
How much cash can I safely carry into the USA and avoid civil forfeiture?
Pulling the rope with one hand is as heavy as with two hands?
Binary Numbers Magic Trick
Combinable filters
Critique of timeline aesthetic
Controversial area of mathematics
What do the phrase "Reeyan's seacrest" and the word "fraggle" mean in a sketch?
How exactly does Hawking radiation decrease the mass of black holes?
Why does nature favour the Laplacian?
French for 'It must be my imagination'?
How to type a section sign ( § ) into the Minecraft client on Linux
What was the first Intel x86 processor with "Base + Index * Scale + Displacement" addressing mode?
Repelling Blast: Must targets always be pushed back?
What does the "ep" capability mean?
What makes accurate emulation of old systems a difficult task?
how to find the equation of a circle given points of the circle
What does KSP mean?
How to pronounce 'C++' in Spanish
Realistic Necromancy?
How to update value in a file using sed linux
Atime value changing only once after file creationHow to put fixed-width, vertically-oriented key-value pairs in a CSV file?How to Prefix a column values with an apostrophe ( ' )?filesystem that works under qemu and I can mount on my hostHow to convert several tiff images into xyz coordinates in a single text file using the terminal?Compare and merge config file in CentOShard vs - in limits.confLinux server deny full accessHow does Linux resolve pathnames with the help of the dentry cache?extract field from file using sed or awk
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
Need to change value corresponding to "root soft nproc" from 180000 to 40000. Sample file look like this:
Any easy way to do this in a single line?
map hard nofile 1000
root soft nofile 1000
root hard nofile 1010
map soft nproc 1200
map hard nproc 1200
root soft nproc 180000
root hard nproc 180000
linux
migrated from serverfault.com 2 days ago
This question came from our site for system and network administrators.
add a comment |
Need to change value corresponding to "root soft nproc" from 180000 to 40000. Sample file look like this:
Any easy way to do this in a single line?
map hard nofile 1000
root soft nofile 1000
root hard nofile 1010
map soft nproc 1200
map hard nproc 1200
root soft nproc 180000
root hard nproc 180000
linux
migrated from serverfault.com 2 days ago
This question came from our site for system and network administrators.
you are getting downvotes because it is OT for here. Ask on unix.stackexchange or superuser.com - and please format the code part properly...
– ivanivan
Apr 20 at 15:24
1
This has almost certainly been asked before
– Timothy Pulliam
Apr 21 at 1:18
add a comment |
Need to change value corresponding to "root soft nproc" from 180000 to 40000. Sample file look like this:
Any easy way to do this in a single line?
map hard nofile 1000
root soft nofile 1000
root hard nofile 1010
map soft nproc 1200
map hard nproc 1200
root soft nproc 180000
root hard nproc 180000
linux
Need to change value corresponding to "root soft nproc" from 180000 to 40000. Sample file look like this:
Any easy way to do this in a single line?
map hard nofile 1000
root soft nofile 1000
root hard nofile 1010
map soft nproc 1200
map hard nproc 1200
root soft nproc 180000
root hard nproc 180000
linux
linux
asked Apr 20 at 14:22
Arpit Garg
migrated from serverfault.com 2 days ago
This question came from our site for system and network administrators.
migrated from serverfault.com 2 days ago
This question came from our site for system and network administrators.
you are getting downvotes because it is OT for here. Ask on unix.stackexchange or superuser.com - and please format the code part properly...
– ivanivan
Apr 20 at 15:24
1
This has almost certainly been asked before
– Timothy Pulliam
Apr 21 at 1:18
add a comment |
you are getting downvotes because it is OT for here. Ask on unix.stackexchange or superuser.com - and please format the code part properly...
– ivanivan
Apr 20 at 15:24
1
This has almost certainly been asked before
– Timothy Pulliam
Apr 21 at 1:18
you are getting downvotes because it is OT for here. Ask on unix.stackexchange or superuser.com - and please format the code part properly...
– ivanivan
Apr 20 at 15:24
you are getting downvotes because it is OT for here. Ask on unix.stackexchange or superuser.com - and please format the code part properly...
– ivanivan
Apr 20 at 15:24
1
1
This has almost certainly been asked before
– Timothy Pulliam
Apr 21 at 1:18
This has almost certainly been asked before
– Timothy Pulliam
Apr 21 at 1:18
add a comment |
1 Answer
1
active
oldest
votes
You can use
sed 's/^(roots*softs*nprocs*)180000$/140000/' file > newfile
to replace the value in place use option -i
sed -i 's/^(roots*softs*nprocs*)180000/140000/' file
Syntax is: sed 's/replace_old/with_new/' file
^matches the beginning of the lines*matches any amount of whitespace characters (spaces and tabs)$matches the end of the line
The part inside (...) is captured in a group and replaced by the following part 140000 where 1 is a backreference to the captured group.
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f515558%2fhow-to-update-value-in-a-file-using-sed-linux%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can use
sed 's/^(roots*softs*nprocs*)180000$/140000/' file > newfile
to replace the value in place use option -i
sed -i 's/^(roots*softs*nprocs*)180000/140000/' file
Syntax is: sed 's/replace_old/with_new/' file
^matches the beginning of the lines*matches any amount of whitespace characters (spaces and tabs)$matches the end of the line
The part inside (...) is captured in a group and replaced by the following part 140000 where 1 is a backreference to the captured group.
add a comment |
You can use
sed 's/^(roots*softs*nprocs*)180000$/140000/' file > newfile
to replace the value in place use option -i
sed -i 's/^(roots*softs*nprocs*)180000/140000/' file
Syntax is: sed 's/replace_old/with_new/' file
^matches the beginning of the lines*matches any amount of whitespace characters (spaces and tabs)$matches the end of the line
The part inside (...) is captured in a group and replaced by the following part 140000 where 1 is a backreference to the captured group.
add a comment |
You can use
sed 's/^(roots*softs*nprocs*)180000$/140000/' file > newfile
to replace the value in place use option -i
sed -i 's/^(roots*softs*nprocs*)180000/140000/' file
Syntax is: sed 's/replace_old/with_new/' file
^matches the beginning of the lines*matches any amount of whitespace characters (spaces and tabs)$matches the end of the line
The part inside (...) is captured in a group and replaced by the following part 140000 where 1 is a backreference to the captured group.
You can use
sed 's/^(roots*softs*nprocs*)180000$/140000/' file > newfile
to replace the value in place use option -i
sed -i 's/^(roots*softs*nprocs*)180000/140000/' file
Syntax is: sed 's/replace_old/with_new/' file
^matches the beginning of the lines*matches any amount of whitespace characters (spaces and tabs)$matches the end of the line
The part inside (...) is captured in a group and replaced by the following part 140000 where 1 is a backreference to the captured group.
answered Apr 20 at 15:43
FreddyFreddy
2,241210
2,241210
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f515558%2fhow-to-update-value-in-a-file-using-sed-linux%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
you are getting downvotes because it is OT for here. Ask on unix.stackexchange or superuser.com - and please format the code part properly...
– ivanivan
Apr 20 at 15:24
1
This has almost certainly been asked before
– Timothy Pulliam
Apr 21 at 1:18