<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to replace a string in a particular line using SED in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/how-to-replace-a-string-in-a-particular-line-using-sed/m-p/3340363#M13373</link>
    <description>If you always have the string to replace under "ProductKey=",then:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;sed "s/ProductKey=.*/ProductKey=aaabbbccdd/g" filename&lt;BR /&gt;&lt;BR /&gt;will do the job...</description>
    <pubDate>Sun, 25 Jul 2004 06:52:25 GMT</pubDate>
    <dc:creator>Alexander Chuzhoy</dc:creator>
    <dc:date>2004-07-25T06:52:25Z</dc:date>
    <item>
      <title>How to replace a string in a particular line using SED</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-replace-a-string-in-a-particular-line-using-sed/m-p/3340358#M13368</link>
      <description>Hi guys,&lt;BR /&gt;&lt;BR /&gt;I have a file(text) file and want to replace a part of string with another string. I've got SED running on a Win XP PC but are having trouble with the syntax.....&lt;BR /&gt;&lt;BR /&gt;For example&lt;BR /&gt;*************&lt;BR /&gt;File contents&lt;BR /&gt;&lt;BR /&gt;ProductKey= "aaaaa-aaaaa-aaaaa-aaaaa-aaaaa"&lt;BR /&gt;&lt;BR /&gt;The above line is somewhere in the middle of the file,which contains around 100 lines.&lt;BR /&gt;I am unable to point to that particular line and replace it.&lt;BR /&gt;&lt;BR /&gt;I have written a script , that prompts for the string to be replaced and if the input is bbbbb-bbbbb-bbbbb-bbbbb-bbbbb (without the quotation marks as in the target file), then the file should be updated as shown below.&lt;BR /&gt;&lt;BR /&gt;ProductKey= "bbbbb-bbbbb-bbbbb-bbbbb-bbbbb"&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Please help me to work this one out...&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;&lt;BR /&gt;Dave.</description>
      <pubDate>Sun, 25 Jul 2004 05:03:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-replace-a-string-in-a-particular-line-using-sed/m-p/3340358#M13368</guid>
      <dc:creator>Dave Faupel</dc:creator>
      <dc:date>2004-07-25T05:03:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace a string in a particular line using SED</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-replace-a-string-in-a-particular-line-using-sed/m-p/3340359#M13369</link>
      <description>Generally it's:&lt;BR /&gt;sed s/string to replace/replacement/ filename&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;where filename is the name ot the file for which you do the replacement.&lt;BR /&gt;If there's more than one occurence of such string you can use :&lt;BR /&gt;s/string to replace/replacement/g filename&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;this will replace all occurences of founded string.</description>
      <pubDate>Sun, 25 Jul 2004 06:08:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-replace-a-string-in-a-particular-line-using-sed/m-p/3340359#M13369</guid>
      <dc:creator>Alexander Chuzhoy</dc:creator>
      <dc:date>2004-07-25T06:08:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace a string in a particular line using SED</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-replace-a-string-in-a-particular-line-using-sed/m-p/3340360#M13370</link>
      <description>if you want script, simply like this:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;sed 's/aaaa/bbbb/' file.txt &amp;gt; changed_file.txt&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;br Jan</description>
      <pubDate>Sun, 25 Jul 2004 06:14:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-replace-a-string-in-a-particular-line-using-sed/m-p/3340360#M13370</guid>
      <dc:creator>Jan Sladky</dc:creator>
      <dc:date>2004-07-25T06:14:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace a string in a particular line using SED</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-replace-a-string-in-a-particular-line-using-sed/m-p/3340361#M13371</link>
      <description>Thanks guys - is there any way to get SED to read upto the first quotation mark and then replace the string in the line within the quotation marks? I'm putting together a script which will take a user input and then replace a product key in a unattend install file. Unfortunatly the string that I'm looking to replace will not always be the same, but I do know that it will always be located following 'ProductKey= "' and end at the second set of the quotation marks. i.e. the string to replace could be 'abcde-abcde-adshs-sdsds-dsdsd' or 'hfgwr-fddfd-dfdfd-yrryy-dgddg' but the string will always follow 'ProductKey= ' i.e&lt;BR /&gt;&lt;BR /&gt;ProductKey= "kjkfd-dfdsf-sfrws-dfdfd-fdfdf"&lt;BR /&gt;&lt;BR /&gt;The string will always be 29 characters in length and will be preceeded by a quotation mark and followed by a quotation mark.&lt;BR /&gt;&lt;BR /&gt;Help appreciated....</description>
      <pubDate>Sun, 25 Jul 2004 06:28:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-replace-a-string-in-a-particular-line-using-sed/m-p/3340361#M13371</guid>
      <dc:creator>Dave Faupel</dc:creator>
      <dc:date>2004-07-25T06:28:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace a string in a particular line using SED</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-replace-a-string-in-a-particular-line-using-sed/m-p/3340362#M13372</link>
      <description>Do not know about your setup / environment but this is how I use it from linux shell prompt.&lt;BR /&gt;&lt;BR /&gt;ex -- if file g.test contains&lt;BR /&gt;&lt;BR /&gt;-----------begin of file--------------&lt;BR /&gt;aa&lt;BR /&gt;bb&lt;BR /&gt;aaaaa-aaaaa-aaaaa-aaaaa-aaaaa&lt;BR /&gt;cc&lt;BR /&gt;dd&lt;BR /&gt;-----------end of file----------------&lt;BR /&gt;&lt;BR /&gt;then type the following &lt;BR /&gt;&lt;BR /&gt;shell_prompt &amp;gt; sed -e s/aaaaa-aaaaa-aaaaa-aaaaa-aaaaa/bbbbb-bbbbb-bbbbb-bbbbb-bbbbb/g g.test&lt;BR /&gt;&lt;BR /&gt;this will display the g.test file and replace the aaa... by bbb..., mind you this does not change the content of the g.test file this interactive form of sed just display the change ! but this is good for testing..&lt;BR /&gt;&lt;BR /&gt;The s/'orig_sting'/repl_string'/g placed in a sed command file will do the substitution for you the /g at the end stands for global (this is if you want to replace every occurence of the string"&lt;BR /&gt;&lt;BR /&gt;Hope this get you codeding.&lt;BR /&gt;&lt;BR /&gt;Jean-Pierre</description>
      <pubDate>Sun, 25 Jul 2004 06:45:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-replace-a-string-in-a-particular-line-using-sed/m-p/3340362#M13372</guid>
      <dc:creator>Huc_1</dc:creator>
      <dc:date>2004-07-25T06:45:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace a string in a particular line using SED</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-replace-a-string-in-a-particular-line-using-sed/m-p/3340363#M13373</link>
      <description>If you always have the string to replace under "ProductKey=",then:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;sed "s/ProductKey=.*/ProductKey=aaabbbccdd/g" filename&lt;BR /&gt;&lt;BR /&gt;will do the job...</description>
      <pubDate>Sun, 25 Jul 2004 06:52:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-replace-a-string-in-a-particular-line-using-sed/m-p/3340363#M13373</guid>
      <dc:creator>Alexander Chuzhoy</dc:creator>
      <dc:date>2004-07-25T06:52:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace a string in a particular line using SED</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-replace-a-string-in-a-particular-line-using-sed/m-p/3340364#M13374</link>
      <description>I should have done a refresh on this note file before I submited my previous reply ... &lt;BR /&gt;&lt;BR /&gt;But Alexander 2 reply seem right to me &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Sorry about my slow typing.&lt;BR /&gt;&lt;BR /&gt;Jean-Pierre</description>
      <pubDate>Sun, 25 Jul 2004 06:57:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-replace-a-string-in-a-particular-line-using-sed/m-p/3340364#M13374</guid>
      <dc:creator>Huc_1</dc:creator>
      <dc:date>2004-07-25T06:57:50Z</dc:date>
    </item>
  </channel>
</rss>

