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;








-1















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









share|improve this question













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

















-1















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









share|improve this question













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













-1












-1








-1








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









share|improve this question














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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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

















  • 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










1 Answer
1






active

oldest

votes


















1














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 line


  • s* 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.






share|improve this answer























    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
    );



    );













    draft saved

    draft discarded


















    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









    1














    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 line


    • s* 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.






    share|improve this answer



























      1














      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 line


      • s* 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.






      share|improve this answer

























        1












        1








        1







        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 line


        • s* 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.






        share|improve this answer













        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 line


        • s* 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.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Apr 20 at 15:43









        FreddyFreddy

        2,241210




        2,241210



























            draft saved

            draft discarded
















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            How to write a 12-bar blues melodyI-IV-V blues progressionHow to play the bridges in a standard blues progressionHow does Gdim7 fit in C# minor?question on a certain chord progressionMusicology of Melody12 bar blues, spread rhythm: alternative to 6th chord to avoid finger stretchChord progressions/ Root key/ MelodiesHow to put chords (POP-EDM) under a given lead vocal melody (starting from a good knowledge in music theory)Are there “rules” for improvising with the minor pentatonic scale over 12-bar shuffle?Confusion about blues scale and chords

            What if the end-user didn't have the required library?What is setup.py?What is a clean, pythonic way to have multiple constructors in Python?What does Ruby have that Python doesn't, and vice versa?What is the reason for having '//' in Python?How do I create a namespace package in Python?How to package shared objects that python modules depend on?setuptools vs. distutils: why is distutils still a thing?Navigation in Windows 10 vs code not going to virtualenv library when the same library is installed at user levelPython create package for local usePackaging a project that uses multiple python versionsWhy is permission denied on pip install except for when “--user” is included at end of command?

            Esgonzo ibérico Índice Descrición Distribución Hábitat Ameazas Notas Véxase tamén "Acerca dos nomes dos anfibios e réptiles galegos""Chalcides bedriagai"Chalcides bedriagai en Carrascal, L. M. Salvador, A. (Eds). Enciclopedia virtual de los vertebrados españoles. Museo Nacional de Ciencias Naturales, Madrid. España.Fotos