Sed - find and run commandwhat is the meaning of 1 at the end of awk scriptsed - find string and...

Why error propagation in CBC mode encryption affect two blocks?

Papers on arXiv solving the same problem at the same time

Given current technology, could TV display screens double as video camera sensors?

Half filled water bottle

Contours of a national emergency in the United States

Does a Mace of Disruption's Frightened effect override undead immunity to the Frightened condition?

Do you pay one or two mana to bounce a transformed Delver of Secrets with Repeal?

Beginner to guitar playing - where should I begin?

Router on a stick not connecting 2 different VLANs

Why is the UK so keen to remove the "backstop" when their leadership seems to think that no border will be needed in Northern Ireland?

What is the name of this plot that has rows with two connected dots?

Why does a sticker slowly peel off, but if it is pulled quickly it tears?

Using Update Cursor within Search Cursor with ArcGIS Pro?

Why is getting a PhD considered "financially irresponsible" by some people?

about to retire but not retired yet, employed but not working any more

What does it take for witness testimony to be believed?

How do you capitalize agile costs with less mature teams?

Can MuseScore be used programmatically?

Why does Windows store Wi-Fi passwords in a reversible format?

Why did my folder names end up like this, and how can I fix this using a script?

Hangman game in Python - need feedback on the quality of code

Is it legal for source code containing undefined behavior to crash the compiler?

Disk usage of integer column vs boolean column in Postgres

What's special ammo in Destiny 2?



Sed - find and run command


what is the meaning of 1 at the end of awk scriptsed - find string and appendCreating multiple input files by using sed in a for loopsed, find and place after and beforesed - find and replace text containing “/”unix: replace one entire column in one file with a single value from another fileSearch pattern in a file and replace substring in the column inlinefind and sed (find and delete)sed: replace strings with variable contentUsing sed command to find and replace codeSed to find and replace regular expression






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







1















I have a file called app.properties like this



prop1.value=hi
prop2.value=hello
prop3.url=https://google.com


As per my requirement, If I see any .value , i need to call an utility function to get the value replaced. just for the example the utility simply multiples the number of chars passed to it * 2.



So, it should become like this.



prop1.value=4
prop2.value=10
prop3.url=https://google.com


I have done simple find and replacement with sed. Not sure how to call any command to replace the value.



  sed -E 's/.value=(.*)/.value=1/g' app.properties


If sed is not correct choice, can you suggest any other alternative?










share|improve this question







New contributor



RamPrakash is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




























    1















    I have a file called app.properties like this



    prop1.value=hi
    prop2.value=hello
    prop3.url=https://google.com


    As per my requirement, If I see any .value , i need to call an utility function to get the value replaced. just for the example the utility simply multiples the number of chars passed to it * 2.



    So, it should become like this.



    prop1.value=4
    prop2.value=10
    prop3.url=https://google.com


    I have done simple find and replacement with sed. Not sure how to call any command to replace the value.



      sed -E 's/.value=(.*)/.value=1/g' app.properties


    If sed is not correct choice, can you suggest any other alternative?










    share|improve this question







    New contributor



    RamPrakash is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.
























      1












      1








      1








      I have a file called app.properties like this



      prop1.value=hi
      prop2.value=hello
      prop3.url=https://google.com


      As per my requirement, If I see any .value , i need to call an utility function to get the value replaced. just for the example the utility simply multiples the number of chars passed to it * 2.



      So, it should become like this.



      prop1.value=4
      prop2.value=10
      prop3.url=https://google.com


      I have done simple find and replacement with sed. Not sure how to call any command to replace the value.



        sed -E 's/.value=(.*)/.value=1/g' app.properties


      If sed is not correct choice, can you suggest any other alternative?










      share|improve this question







      New contributor



      RamPrakash is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      I have a file called app.properties like this



      prop1.value=hi
      prop2.value=hello
      prop3.url=https://google.com


      As per my requirement, If I see any .value , i need to call an utility function to get the value replaced. just for the example the utility simply multiples the number of chars passed to it * 2.



      So, it should become like this.



      prop1.value=4
      prop2.value=10
      prop3.url=https://google.com


      I have done simple find and replacement with sed. Not sure how to call any command to replace the value.



        sed -E 's/.value=(.*)/.value=1/g' app.properties


      If sed is not correct choice, can you suggest any other alternative?







      sed






      share|improve this question







      New contributor



      RamPrakash is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.










      share|improve this question







      New contributor



      RamPrakash is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.








      share|improve this question




      share|improve this question






      New contributor



      RamPrakash is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.








      asked 3 hours ago









      RamPrakashRamPrakash

      82 bronze badges




      82 bronze badges




      New contributor



      RamPrakash is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




      New contributor




      RamPrakash is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.



























          1 Answer
          1






          active

          oldest

          votes


















          1















          How about



          $ awk 'BEGIN{OFS=FS="="} $1 ~ /.value$/ {$2 = 2 * length($2)} 1' app.properties 
          prop1.value=4
          prop2.value=10
          prop3.url=https://google.com


          If you want something closer to your sed approach, then perhaps



          perl -pe 's/.value=(.*)/sprintf ".value=%s", 2 * length $1/e' app.properties


          or



          perl -pe 's/(?<=.value=).*/2 * length $&/e' app.properties





          share|improve this answer


























          • you are genius! Would you explain what does the 1 {$2 = 2 * length($2)} 1' do here?

            – RamPrakash
            1 hour ago













          • @RamPrakash please see what is the meaning of 1 at the end of awk script

            – steeldriver
            24 mins ago














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


          }
          });






          RamPrakash is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f537560%2fsed-find-and-run-command%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















          How about



          $ awk 'BEGIN{OFS=FS="="} $1 ~ /.value$/ {$2 = 2 * length($2)} 1' app.properties 
          prop1.value=4
          prop2.value=10
          prop3.url=https://google.com


          If you want something closer to your sed approach, then perhaps



          perl -pe 's/.value=(.*)/sprintf ".value=%s", 2 * length $1/e' app.properties


          or



          perl -pe 's/(?<=.value=).*/2 * length $&/e' app.properties





          share|improve this answer


























          • you are genius! Would you explain what does the 1 {$2 = 2 * length($2)} 1' do here?

            – RamPrakash
            1 hour ago













          • @RamPrakash please see what is the meaning of 1 at the end of awk script

            – steeldriver
            24 mins ago
















          1















          How about



          $ awk 'BEGIN{OFS=FS="="} $1 ~ /.value$/ {$2 = 2 * length($2)} 1' app.properties 
          prop1.value=4
          prop2.value=10
          prop3.url=https://google.com


          If you want something closer to your sed approach, then perhaps



          perl -pe 's/.value=(.*)/sprintf ".value=%s", 2 * length $1/e' app.properties


          or



          perl -pe 's/(?<=.value=).*/2 * length $&/e' app.properties





          share|improve this answer


























          • you are genius! Would you explain what does the 1 {$2 = 2 * length($2)} 1' do here?

            – RamPrakash
            1 hour ago













          • @RamPrakash please see what is the meaning of 1 at the end of awk script

            – steeldriver
            24 mins ago














          1














          1










          1









          How about



          $ awk 'BEGIN{OFS=FS="="} $1 ~ /.value$/ {$2 = 2 * length($2)} 1' app.properties 
          prop1.value=4
          prop2.value=10
          prop3.url=https://google.com


          If you want something closer to your sed approach, then perhaps



          perl -pe 's/.value=(.*)/sprintf ".value=%s", 2 * length $1/e' app.properties


          or



          perl -pe 's/(?<=.value=).*/2 * length $&/e' app.properties





          share|improve this answer













          How about



          $ awk 'BEGIN{OFS=FS="="} $1 ~ /.value$/ {$2 = 2 * length($2)} 1' app.properties 
          prop1.value=4
          prop2.value=10
          prop3.url=https://google.com


          If you want something closer to your sed approach, then perhaps



          perl -pe 's/.value=(.*)/sprintf ".value=%s", 2 * length $1/e' app.properties


          or



          perl -pe 's/(?<=.value=).*/2 * length $&/e' app.properties






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 3 hours ago









          steeldriversteeldriver

          42.6k5 gold badges56 silver badges94 bronze badges




          42.6k5 gold badges56 silver badges94 bronze badges
















          • you are genius! Would you explain what does the 1 {$2 = 2 * length($2)} 1' do here?

            – RamPrakash
            1 hour ago













          • @RamPrakash please see what is the meaning of 1 at the end of awk script

            – steeldriver
            24 mins ago



















          • you are genius! Would you explain what does the 1 {$2 = 2 * length($2)} 1' do here?

            – RamPrakash
            1 hour ago













          • @RamPrakash please see what is the meaning of 1 at the end of awk script

            – steeldriver
            24 mins ago

















          you are genius! Would you explain what does the 1 {$2 = 2 * length($2)} 1' do here?

          – RamPrakash
          1 hour ago







          you are genius! Would you explain what does the 1 {$2 = 2 * length($2)} 1' do here?

          – RamPrakash
          1 hour ago















          @RamPrakash please see what is the meaning of 1 at the end of awk script

          – steeldriver
          24 mins ago





          @RamPrakash please see what is the meaning of 1 at the end of awk script

          – steeldriver
          24 mins ago










          RamPrakash is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          RamPrakash is a new contributor. Be nice, and check out our Code of Conduct.













          RamPrakash is a new contributor. Be nice, and check out our Code of Conduct.












          RamPrakash is a new contributor. Be nice, and check out our Code of Conduct.
















          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%2f537560%2fsed-find-and-run-command%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

          Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

          Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

          Nicolae Petrescu-Găină Cuprins Biografie | Opera | In memoriam | Varia | Controverse, incertitudini...