<?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: Shell Script Help in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/shell-script-help/m-p/3738941#M101249</link>
    <description>Hi Steven:&lt;BR /&gt;&lt;BR /&gt;If I read your requirements and attachments correctly, simply adding the beginning-of-line anchor (the caret) to each substitution (as follows) will produce what you want:&lt;BR /&gt;&lt;BR /&gt;sed -e 's/^EMAIL_ADDR_TXT/AGENCY_LOCATION/' &lt;BR /&gt;-e 's/^CONT_EMAIL_ADDR_TXT/AGENCY_CONTACT/' &lt;BR /&gt;-e 's/^EMX_ADDR/WEB_APPLICANT/' &lt;BR /&gt;-e 's/^SITE_EMAIL_ADDR_TXT/RESOURCE_LOCATION/' $BADMAIL&amp;gt;badmail1&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Fri, 24 Feb 2006 13:03:52 GMT</pubDate>
    <dc:creator>James R. Ferguson</dc:creator>
    <dc:date>2006-02-24T13:03:52Z</dc:date>
    <item>
      <title>Shell Script Help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script-help/m-p/3738930#M101238</link>
      <description>Hope someone can help:&lt;BR /&gt;&lt;BR /&gt;I have the following script:&lt;BR /&gt;&lt;BR /&gt;sed -e 's/EMAIL_ADDR_TXT/AGENCY_LOCATION/' &lt;BR /&gt;-e 's/CONT_EMAIL_ADDR_TXT/AGENCY_CONTACT/' &lt;BR /&gt;-e 's/EMX_ADDR/WEB_APPLICANT/' &lt;BR /&gt;-e 's/SITE_EMAIL_ADDR_TXT/RESOURCE_LOCATION/' $BADMAIL&amp;gt;badmail1&lt;BR /&gt;&lt;BR /&gt;but the result is all words of EMAIL_ADDR_TXT have been changed to AGENCY_LOCATION, the first sed choice.&lt;BR /&gt;&lt;BR /&gt;I need some field protection and change the word to exactly what it means.  But using [ ] to include words still not working.    Nor I succeeds in using " " to protect.&lt;BR /&gt;&lt;BR /&gt;Any comments are appreciated. &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 24 Feb 2006 09:19:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script-help/m-p/3738930#M101238</guid>
      <dc:creator>Steven Chen_1</dc:creator>
      <dc:date>2006-02-24T09:19:57Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script Help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script-help/m-p/3738931#M101239</link>
      <description>Steven,&lt;BR /&gt;is there a field seperator in the file?&lt;BR /&gt;&lt;BR /&gt;If, for example it is "," you could do&lt;BR /&gt;sed -e's/,EMAIL_ADDR_TXT,/,AGENCY_LOCATION,/&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 24 Feb 2006 09:26:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script-help/m-p/3738931#M101239</guid>
      <dc:creator>Peter Godron</dc:creator>
      <dc:date>2006-02-24T09:26:16Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script Help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script-help/m-p/3738932#M101240</link>
      <description>Hi Steven:&lt;BR /&gt;&lt;BR /&gt;You need to provide a better regular expression -- one that uniquely identifies the boundries of a match/substitution.&lt;BR /&gt;&lt;BR /&gt;For example, anchor EMAIL_ADDR_TXT to the beginning of a line with a caret:&lt;BR /&gt;&lt;BR /&gt;sed -e 's/^EMAIL_ADDR_TXT/&lt;BR /&gt;&lt;BR /&gt;You can anchor at the end of a line with a dollar sign ($).  You can use spaces and tabs too to form logical boundries.&lt;BR /&gt;&lt;BR /&gt;Far, far superior to 'sed' is 'perl'.  Perl has some of the very best regular expression support you can find, in my opinion.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Fri, 24 Feb 2006 09:32:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script-help/m-p/3738932#M101240</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-02-24T09:32:46Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script Help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script-help/m-p/3738933#M101241</link>
      <description>Hi Steven,&lt;BR /&gt;&lt;BR /&gt;I guess you need to use the global option (/g) option, just like in vi :%s/&lt;SEARCH&gt;/&lt;REPLACE&gt;/g &lt;BR /&gt;&lt;BR /&gt;So the syntax would be:&lt;BR /&gt;sed -e 's/EMAIL_ADDR_TXT/AGENCY_LOCATION/g'\ &lt;BR /&gt;-e 's/CONT_EMAIL_ADDR_TXT/AGENCY_CONTACT/g'\ &lt;BR /&gt;-e 's/EMX_ADDR/WEB_APPLICANT/g'\&lt;BR /&gt;-e 's/SITE_EMAIL_ADDR_TXT/RESOURCE_LOCATION/g'\&lt;BR /&gt;$BADMAIL&amp;gt;badmail1&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;&lt;BR /&gt;Renarios&lt;/REPLACE&gt;&lt;/SEARCH&gt;</description>
      <pubDate>Fri, 24 Feb 2006 09:37:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script-help/m-p/3738933#M101241</guid>
      <dc:creator>renarios</dc:creator>
      <dc:date>2006-02-24T09:37:30Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script Help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script-help/m-p/3738934#M101242</link>
      <description>Hi, &lt;BR /&gt;&lt;BR /&gt;A very good reading about "sed"&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://www.student.northpark.edu/pemente/sed/sed1line.txt" target="_blank"&gt;http://www.student.northpark.edu/pemente/sed/sed1line.txt&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;-Arun</description>
      <pubDate>Fri, 24 Feb 2006 09:57:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script-help/m-p/3738934#M101242</guid>
      <dc:creator>Arunvijai_4</dc:creator>
      <dc:date>2006-02-24T09:57:43Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script Help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script-help/m-p/3738935#M101243</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;as a first change, you could change the order of the sed-commands: since the command sequence of sed is in serial order, put the longest strings first: they have been changed already when sed executes the following command(s).&lt;BR /&gt;sed -e 's/CONT_EMAIL_ADDR_TXT/AGENCY_CONTACT/' &lt;BR /&gt;-e 's/SITE_EMAIL_ADDR_TXT/RESOURCE_LOCATION/' &lt;BR /&gt;-e 's/EMAIL_ADDR_TXT/AGENCY_LOCATION/'  ...&lt;BR /&gt;&lt;BR /&gt;If there is always at least one character of text before the search pattern, you can anchor it (like the other posters suggested). Pattern starting at the beginning of a line must be added seperately:&lt;BR /&gt;&lt;BR /&gt;sed -e  's/\([^_]\)EMAIL_ADDR_TXT/\1AGENCY_LOCATION/' -e 's/^EMAIL_ADDR_TXT/AGENCY_LOCATION/'&lt;BR /&gt;..&lt;BR /&gt;and so on. If the overlapping search pattern differ not in the '_' unterline, the anchor pattern has to be refined, perhaps you need a different anchor pattern for the end of the search pattern.&lt;BR /&gt;&lt;BR /&gt;mfG Peter</description>
      <pubDate>Fri, 24 Feb 2006 11:10:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script-help/m-p/3738935#M101243</guid>
      <dc:creator>Peter Nikitka</dc:creator>
      <dc:date>2006-02-24T11:10:43Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script Help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script-help/m-p/3738936#M101244</link>
      <description>Hello!&lt;BR /&gt;&lt;BR /&gt;I'm not sure if your question has been answered by one of the aforementioned posts, but it'll help if you could attach a portion of the input file on which these sed substitutions have to occur. These would definitely help in providing an accurate solution to your problem.&lt;BR /&gt;&lt;BR /&gt;cheers!</description>
      <pubDate>Fri, 24 Feb 2006 11:13:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script-help/m-p/3738936#M101244</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2006-02-24T11:13:42Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script Help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script-help/m-p/3738937#M101245</link>
      <description>Hi,&lt;BR /&gt;try:&lt;BR /&gt;sed -e 's/SITE_EMAIL_ADDR_TXT/RESOURCE_LOCATION/'&lt;BR /&gt;-e 's/CONT_EMAIL_ADDR_TXT/AGENCY_CONTACT/' &lt;BR /&gt;-e 's/EMX_ADDR/WEB_APPLICANT/' &lt;BR /&gt;-e 's/EMAIL_ADDR_TXT/AGENCY_LOCATION/' $BADMAIL&amp;gt;badmail1&lt;BR /&gt;&lt;BR /&gt;Since Sed exceutes the commands in order, first chnage the long pattern and after the pattern contained into previous pattern already chnaged.&lt;BR /&gt;HTH,&lt;BR /&gt;Art&lt;BR /&gt;</description>
      <pubDate>Fri, 24 Feb 2006 11:15:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script-help/m-p/3738937#M101245</guid>
      <dc:creator>Arturo Galbiati</dc:creator>
      <dc:date>2006-02-24T11:15:15Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script Help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script-help/m-p/3738938#M101246</link>
      <description>I am going to attach original source file "badmail.lst" (=$BADMAIL) and the resulting file using my script.   Maybe you could find out the solution.&lt;BR /&gt;&lt;BR /&gt;Thanks a lot and have fun.</description>
      <pubDate>Fri, 24 Feb 2006 11:57:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script-help/m-p/3738938#M101246</guid>
      <dc:creator>Steven Chen_1</dc:creator>
      <dc:date>2006-02-24T11:57:25Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script Help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script-help/m-p/3738939#M101247</link>
      <description>Hello Steven, &lt;BR /&gt;&lt;BR /&gt;What exactly you want to do ? Its always better to use perl for regular expressions. &lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://www.english.uga.edu/humcomp/perl/regex2a.html" target="_blank"&gt;http://www.english.uga.edu/humcomp/perl/regex2a.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;-Arun</description>
      <pubDate>Fri, 24 Feb 2006 12:04:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script-help/m-p/3738939#M101247</guid>
      <dc:creator>Arunvijai_4</dc:creator>
      <dc:date>2006-02-24T12:04:30Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script Help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script-help/m-p/3738940#M101248</link>
      <description>Steven,&lt;BR /&gt;&lt;BR /&gt;Try the ex script provided below. It's more useful than sed as it can anchor words with \&amp;lt; (start-of-word) \&amp;gt; (end-of-word) and substitute exactly those instead of substrings that are contained within words. In other words it provides the field protection you are looking for.&lt;BR /&gt;&lt;BR /&gt;# ex -s $BADMAIL&amp;lt;&lt;EOF&gt;&lt;/EOF&gt;&amp;gt; 1,$ s/\&lt;EMAIL_ADDR_TXT&gt;/AGENCY_LOCATION/g&lt;BR /&gt;&amp;gt; 1,$ s/\&lt;CONT_EMAIL_ADDR_TXT&gt;/AGENCY_CONTACT/g&lt;BR /&gt;&amp;gt; 1,$ s/\&lt;EMX_ADDR&gt;/WEB_APPLICANT/g&lt;BR /&gt;&amp;gt; 1,$ s/\&lt;SITE_EMAIL_ADDR_TXT&gt;/RESOURCE_LOCATION/g&lt;BR /&gt;&amp;gt; w badmail1&lt;BR /&gt;&amp;gt; EOF&lt;BR /&gt;&lt;BR /&gt;In fact it can modify the input file without having to pipe stdout to another file. If you wanted to modify and save the changes to $BADMAIL itself then change the "w badmail1" command to "wq" i.e.&lt;BR /&gt;&lt;BR /&gt;# ex -s $BADMAIL&amp;lt;&lt;EOF&gt;&lt;/EOF&gt;&amp;gt; 1,$ s/\&lt;EMAIL_ADDR_TXT&gt;/AGENCY_LOCATION/g&lt;BR /&gt;&amp;gt; 1,$ s/\&lt;CONT_EMAIL_ADDR_TXT&gt;/AGENCY_CONTACT/g&lt;BR /&gt;&amp;gt; 1,$ s/\&lt;EMX_ADDR&gt;/WEB_APPLICANT/g&lt;BR /&gt;&amp;gt; 1,$ s/\&lt;SITE_EMAIL_ADDR_TXT&gt;/RESOURCE_LOCATION/g&lt;BR /&gt;&amp;gt; wq&lt;BR /&gt;&amp;gt; EOF&lt;BR /&gt;&lt;BR /&gt;hope it helps!&lt;/SITE_EMAIL_ADDR_TXT&gt;&lt;/EMX_ADDR&gt;&lt;/CONT_EMAIL_ADDR_TXT&gt;&lt;/EMAIL_ADDR_TXT&gt;&lt;/SITE_EMAIL_ADDR_TXT&gt;&lt;/EMX_ADDR&gt;&lt;/CONT_EMAIL_ADDR_TXT&gt;&lt;/EMAIL_ADDR_TXT&gt;</description>
      <pubDate>Fri, 24 Feb 2006 13:03:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script-help/m-p/3738940#M101248</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2006-02-24T13:03:11Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script Help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script-help/m-p/3738941#M101249</link>
      <description>Hi Steven:&lt;BR /&gt;&lt;BR /&gt;If I read your requirements and attachments correctly, simply adding the beginning-of-line anchor (the caret) to each substitution (as follows) will produce what you want:&lt;BR /&gt;&lt;BR /&gt;sed -e 's/^EMAIL_ADDR_TXT/AGENCY_LOCATION/' &lt;BR /&gt;-e 's/^CONT_EMAIL_ADDR_TXT/AGENCY_CONTACT/' &lt;BR /&gt;-e 's/^EMX_ADDR/WEB_APPLICANT/' &lt;BR /&gt;-e 's/^SITE_EMAIL_ADDR_TXT/RESOURCE_LOCATION/' $BADMAIL&amp;gt;badmail1&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 24 Feb 2006 13:03:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script-help/m-p/3738941#M101249</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-02-24T13:03:52Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script Help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script-help/m-p/3738942#M101250</link>
      <description>As always, I am fascinated by the overwhelming support and the precise solution folks are providing!&lt;BR /&gt;&lt;BR /&gt;for the benefit of all, my trial passes and the verdict comes out that JRF's solution is simple, precise and get the work done!&lt;BR /&gt;&lt;BR /&gt;Thank you all!</description>
      <pubDate>Fri, 24 Feb 2006 14:15:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script-help/m-p/3738942#M101250</guid>
      <dc:creator>Steven Chen_1</dc:creator>
      <dc:date>2006-02-24T14:15:13Z</dc:date>
    </item>
  </channel>
</rss>

