<?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: Using sed in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/using-sed/m-p/3136348#M900730</link>
    <description>Okay I misread it...&lt;BR /&gt;&lt;BR /&gt;This will work if you are explicit.&lt;BR /&gt;&lt;BR /&gt;sed 's/CFG_FILE /CFG_FILE_TEMP/g' &amp;lt; file.in &amp;gt; file.out &lt;BR /&gt;&lt;BR /&gt;Ensure there is a space after the CFG_FILE, this will only change the ones that are explicitly CFG_FILE and not the CFG_FILE_INPUT variable.</description>
    <pubDate>Thu, 04 Dec 2003 16:21:54 GMT</pubDate>
    <dc:creator>Todd McDaniel_1</dc:creator>
    <dc:date>2003-12-04T16:21:54Z</dc:date>
    <item>
      <title>Using sed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-sed/m-p/3136337#M900719</link>
      <description>Suppose I have a file as follows:&lt;BR /&gt;&lt;BR /&gt;VAR1=VALUE1&lt;BR /&gt;VAR1=VALUE1 #Some comment with a tab&lt;BR /&gt;VAR1=VALUE1     #Some comment with spaces&lt;BR /&gt;VAR11=VALUE11&lt;BR /&gt;VAR11=VALUE11 #Some comment with a tab&lt;BR /&gt;VAR11=VALUE11   #Some comment with spaces&lt;BR /&gt;&lt;BR /&gt;I want to substitute all the VALUE1's with some other value say VALUE2, but without changing VALUE11.&lt;BR /&gt;Ideally the output file should be as follows&lt;BR /&gt;&lt;BR /&gt;VAR1=VALUE2&lt;BR /&gt;VAR1=VALUE2 #Some comment with a tab&lt;BR /&gt;VAR1=VALUE2     #Some comment with spaces&lt;BR /&gt;VAR11=VALUE11&lt;BR /&gt;VAR11=VALUE11 #Some comment with a tab&lt;BR /&gt;VAR11=VALUE11   #Some comment with spaces&lt;BR /&gt;&lt;BR /&gt;I tried using 'sed' with regular expressions but it doesnt seem to be working.&lt;BR /&gt;It would be great if somebody can enlighten me on this.&lt;BR /&gt;&lt;BR /&gt;Cheers&lt;BR /&gt;Deepak&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 04 Dec 2003 11:44:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-sed/m-p/3136337#M900719</guid>
      <dc:creator>Deepak BS</dc:creator>
      <dc:date>2003-12-04T11:44:40Z</dc:date>
    </item>
    <item>
      <title>Re: Using sed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-sed/m-p/3136338#M900720</link>
      <description>Im confused... you can't define the same variable 3 different times.&lt;BR /&gt;&lt;BR /&gt;Also, changing a variable for one doesnt affect the other variable.&lt;BR /&gt;&lt;BR /&gt;I am really confused as to your logic, can you post again and explain further? &lt;BR /&gt;&lt;BR /&gt;Changing a variable is simple, just change it from value1 to value2.</description>
      <pubDate>Thu, 04 Dec 2003 11:50:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-sed/m-p/3136338#M900720</guid>
      <dc:creator>Todd McDaniel_1</dc:creator>
      <dc:date>2003-12-04T11:50:51Z</dc:date>
    </item>
    <item>
      <title>Re: Using sed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-sed/m-p/3136339#M900721</link>
      <description>Search for "VAR1=VALUE1" string and replace with "VAR1=VALUE2"&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;</description>
      <pubDate>Thu, 04 Dec 2003 11:51:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-sed/m-p/3136339#M900721</guid>
      <dc:creator>DIPAK KUMAR ROY</dc:creator>
      <dc:date>2003-12-04T11:51:34Z</dc:date>
    </item>
    <item>
      <title>Re: Using sed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-sed/m-p/3136340#M900722</link>
      <description>Haha, I think it sounded too generic.&lt;BR /&gt;OK, assume there are 2 different name value pairs.&lt;BR /&gt;&lt;BR /&gt;CONFIG_FILE=$CFG_FILE&lt;BR /&gt;CONFIG_FILE_INPUT=$CFG_FILE_INPUT&lt;BR /&gt;&lt;BR /&gt;Now, through a script I want to change CFG_FILE to CFG_FILE_TEMP. That is, I am _not_ doing it manually :)&lt;BR /&gt;&lt;BR /&gt;So, if I use 'sed' to replace CFG_FILE to CFG_FILE_TEMP, then both these lines will get affected, which is what I do _not_ want.&lt;BR /&gt;&lt;BR /&gt;After replacing, I want the file to be:&lt;BR /&gt;CONFIG_FILE=$CFG_FILE_TEMP&lt;BR /&gt;CONFIG_FILE_INPUT=$CFG_FILE_INPUT&lt;BR /&gt;&lt;BR /&gt;and _not_&lt;BR /&gt;&lt;BR /&gt;CONFIG_FILE=$CFG_FILE_TEMP&lt;BR /&gt;CONFIG_FILE_INPUT=$CFG_FILE_TEMP_INPUT&lt;BR /&gt;&lt;BR /&gt;I hope somebody understood my simple yet unique problem :)&lt;BR /&gt;&lt;BR /&gt;Cheers&lt;BR /&gt;Deepak&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 04 Dec 2003 12:04:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-sed/m-p/3136340#M900722</guid>
      <dc:creator>Deepak BS</dc:creator>
      <dc:date>2003-12-04T12:04:45Z</dc:date>
    </item>
    <item>
      <title>Re: Using sed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-sed/m-p/3136341#M900723</link>
      <description>If you have vim, then open the file and do like this :%s:\&lt;VALUE1&gt;:VALUE2:g&lt;BR /&gt;&lt;BR /&gt;This will do.  I think the gnu versions of sed support this.&lt;BR /&gt;&lt;BR /&gt;HTH,&lt;BR /&gt;Umapathy&lt;/VALUE1&gt;</description>
      <pubDate>Thu, 04 Dec 2003 12:09:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-sed/m-p/3136341#M900723</guid>
      <dc:creator>Umapathy S</dc:creator>
      <dc:date>2003-12-04T12:09:01Z</dc:date>
    </item>
    <item>
      <title>Re: Using sed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-sed/m-p/3136342#M900724</link>
      <description>I am doing it non-interactively. So, I cant use vi, vim etc</description>
      <pubDate>Thu, 04 Dec 2003 12:49:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-sed/m-p/3136342#M900724</guid>
      <dc:creator>Deepak BS</dc:creator>
      <dc:date>2003-12-04T12:49:15Z</dc:date>
    </item>
    <item>
      <title>Re: Using sed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-sed/m-p/3136343#M900725</link>
      <description># perl -pe's/\bVALUE1\b/VALUE2/g' file&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Thu, 04 Dec 2003 12:53:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-sed/m-p/3136343#M900725</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2003-12-04T12:53:22Z</dc:date>
    </item>
    <item>
      <title>Re: Using sed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-sed/m-p/3136344#M900726</link>
      <description>Here is a sed option...if you want to change value to val, in this example.&lt;BR /&gt;&lt;BR /&gt;sed 's/CFG_FILE/CFG_FILE_TEMP/g' &amp;lt; file.in &amp;gt; file.out</description>
      <pubDate>Thu, 04 Dec 2003 13:39:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-sed/m-p/3136344#M900726</guid>
      <dc:creator>Todd McDaniel_1</dc:creator>
      <dc:date>2003-12-04T13:39:32Z</dc:date>
    </item>
    <item>
      <title>Re: Using sed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-sed/m-p/3136345#M900727</link>
      <description>What you need to do is define a way for your editor (sed/perl/awk/...) to find out what to change and what not. Merijn/Procura did it with the \b meaning a blank (I think, don't have docs to verify it right now), but does this work correctly? Since there is a '=' instead of a blank before what you want to change...&lt;BR /&gt;&lt;BR /&gt;Using sed, it would be something like this:&lt;BR /&gt;sed -e 's|CFG_FILE *$|CFG_FILE_TEMP|" -e "s|CFG_FILE\( *#.*\)$|CFG_FILE_TEMP\1|" &lt;IN-FILE&gt;out-file&lt;BR /&gt;&lt;BR /&gt;&lt;/IN-FILE&gt;</description>
      <pubDate>Thu, 04 Dec 2003 14:02:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-sed/m-p/3136345#M900727</guid>
      <dc:creator>Elmar P. Kolkman</dc:creator>
      <dc:date>2003-12-04T14:02:48Z</dc:date>
    </item>
    <item>
      <title>Re: Using sed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-sed/m-p/3136346#M900728</link>
      <description>Elmar, NOOOOO! \b in perl is a word boundary. White space is \s&lt;BR /&gt;&lt;BR /&gt;\&amp;lt; is begin of word in vi/elvis/vim/some-versions-of-grep and \&amp;gt; is end of word&lt;BR /&gt;perl only has \b which drills down to a zero width asserion between \w (a word character) and \W|^|$ (a non-word character, begin of line, end of line)&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Thu, 04 Dec 2003 14:28:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-sed/m-p/3136346#M900728</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2003-12-04T14:28:47Z</dc:date>
    </item>
    <item>
      <title>Re: Using sed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-sed/m-p/3136347#M900729</link>
      <description>Am I having a bad day or is this really tricky in SED?&lt;BR /&gt;&lt;BR /&gt;I can not get an regexpr to match "end-of-line" or whitepace. The $ end-of-line anchor does not seem to cut it, The (|) alternate match does not seem to cut it.&lt;BR /&gt;&lt;BR /&gt;Todd: Your suggestion will replace VALUE11 by VALUE21 which was explicitly described as to be avoided, otherwise Deepak would not have posted the question!&lt;BR /&gt;&lt;BR /&gt;Elmar: No, \b is a boundary, not a character which is just as well otherwise it would be 'eaten'. COmpare to ^ and $ somewhat.&lt;BR /&gt;&lt;BR /&gt;Deepak: for a general solution it would seem to me you need regular subexpression to anchor your target string and be able to get the anchors back in the output.&lt;BR /&gt;For example, is you'd use a simple:&lt;BR /&gt;sed 's/LUE1[[:blank:]]/LUE2/g'  xxx&lt;BR /&gt;The result is: VAR1=VALUE2#Some&lt;BR /&gt;Instead of: VAR1=VALUE2 #Some&lt;BR /&gt;&lt;BR /&gt;It was easy in Perl, but with sed to best I can come up with so far is not good enough:&lt;BR /&gt;&lt;BR /&gt;sed -e 's/\([^[:alnum:]]\)VALUE1\([^[:alnum:]]\)/\1VALUE2\2/g' -e 's/VALUE1$/VALUE2/' xxx&lt;BR /&gt;&lt;BR /&gt;Here the last part deals with the end-of-line occurence, the other part finds the target surrounded with non-alphanumerics, remembers those surroundings and uses them with the replace string. Yuck.&lt;BR /&gt;&lt;BR /&gt;In grep  you can use:&lt;BR /&gt;grep -E 'LUE1($|[ \t])' xxx&lt;BR /&gt;or:&lt;BR /&gt;grep -E 'LUE1($|[^[:alnum:]])' xxx&lt;BR /&gt; &lt;BR /&gt;So how does one match on EOL or SPACE in sed?&lt;BR /&gt;&lt;BR /&gt;The $ want to start a shell variable, and a simple escape (\) does not fix that I believe.&lt;BR /&gt;&lt;BR /&gt;fwiw,&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 04 Dec 2003 15:15:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-sed/m-p/3136347#M900729</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2003-12-04T15:15:39Z</dc:date>
    </item>
    <item>
      <title>Re: Using sed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-sed/m-p/3136348#M900730</link>
      <description>Okay I misread it...&lt;BR /&gt;&lt;BR /&gt;This will work if you are explicit.&lt;BR /&gt;&lt;BR /&gt;sed 's/CFG_FILE /CFG_FILE_TEMP/g' &amp;lt; file.in &amp;gt; file.out &lt;BR /&gt;&lt;BR /&gt;Ensure there is a space after the CFG_FILE, this will only change the ones that are explicitly CFG_FILE and not the CFG_FILE_INPUT variable.</description>
      <pubDate>Thu, 04 Dec 2003 16:21:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-sed/m-p/3136348#M900730</guid>
      <dc:creator>Todd McDaniel_1</dc:creator>
      <dc:date>2003-12-04T16:21:54Z</dc:date>
    </item>
    <item>
      <title>Re: Using sed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-sed/m-p/3136349#M900731</link>
      <description>Sorry, but still wrong.... still did not read right. &lt;BR /&gt;nitpicking... nothing personal... just trying to help and all that!&lt;BR /&gt;&lt;BR /&gt;Deepak was very explicit about the target potentially being followed by a space, tab or nothing.&lt;BR /&gt;It was implied, but not explicit, that he would not want to touch a line with 'VAR1=OTHERVALUE1 #differnt variable'&lt;BR /&gt;&lt;BR /&gt;Cheers!&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 04 Dec 2003 17:16:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-sed/m-p/3136349#M900731</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2003-12-04T17:16:39Z</dc:date>
    </item>
    <item>
      <title>Re: Using sed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-sed/m-p/3136350#M900732</link>
      <description>sed \&lt;BR /&gt; -e 's/CFG_FILE$/CFG_FILE_TEMP/g' \&lt;BR /&gt; -e 's/CFG_FILE[  ]/CFG_FILE_TEMP/g' &lt;BR /&gt;&lt;BR /&gt;where&lt;BR /&gt; . the first expression (-e) gets the end-of-line case&lt;BR /&gt; . the second expression (-e) gets the white-space (one or more tabs and/or blanks) and the [..] is entered in the script as a blank followed by a tab.  On the command line, the tab can be entered as a ^V^I (ctl-V ctl-I) when in Posix/ksh/bash.  In the Bourne shell, you can simply hit the tab key.  I also noticed that you can simply hit the tab in HP-UX Posix/ksh shell.  (I generally use ^V^I because it also works in Linux bash).&lt;BR /&gt;&lt;BR /&gt;bv</description>
      <pubDate>Fri, 05 Dec 2003 15:27:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-sed/m-p/3136350#M900732</guid>
      <dc:creator>Bob_Vance</dc:creator>
      <dc:date>2003-12-05T15:27:30Z</dc:date>
    </item>
    <item>
      <title>Re: Using sed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-sed/m-p/3136351#M900733</link>
      <description>&amp;gt; the second expression (-e) gets the white-space (one or more tabs and/or blanks) and the [..] is entered in the script as a blank followed by a tab. &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Fine... but does that not stripe a tab or space from the text once replaced? How do you propose to return that exact character?&lt;BR /&gt;&lt;BR /&gt;Hein.</description>
      <pubDate>Fri, 05 Dec 2003 23:24:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-sed/m-p/3136351#M900733</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2003-12-05T23:24:19Z</dc:date>
    </item>
    <item>
      <title>Re: Using sed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-sed/m-p/3136352#M900734</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt; # cat sed.dat&lt;BR /&gt;VAR1=VALUE1&lt;BR /&gt;VAR1=VALUE1     #Some comment with a tab&lt;BR /&gt;VAR1=VALUE1 #Some comment with a space&lt;BR /&gt;VAR11=VALUE11&lt;BR /&gt;VAR11=VALUE11   # Some comment with a tab&lt;BR /&gt;VAR11=VALUE11 # Some comment with a space&lt;BR /&gt; # sed \&lt;BR /&gt;-e 's/VALUE1\([    ]\)/VALUE2\1/g' \&lt;BR /&gt;-e 's/VALUE1$/VALUE2/' sed.dat&lt;BR /&gt;VAR1=VALUE2&lt;BR /&gt;VAR1=VALUE2     #Some comment with a tab&lt;BR /&gt;VAR1=VALUE2 #Some comment with a space&lt;BR /&gt;VAR11=VALUE11&lt;BR /&gt;VAR11=VALUE11   # Some comment with a tab&lt;BR /&gt;VAR11=VALUE11 # Some comment with a space&lt;BR /&gt; #&lt;BR /&gt;&lt;BR /&gt;In HP posix sh you type in the actual tab char in the [...] char class.&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;  JW.</description>
      <pubDate>Sun, 07 Dec 2003 19:49:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-sed/m-p/3136352#M900734</guid>
      <dc:creator>John Wright_1</dc:creator>
      <dc:date>2003-12-07T19:49:31Z</dc:date>
    </item>
    <item>
      <title>Re: Using sed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-sed/m-p/3136353#M900735</link>
      <description>Good catch, Hein !!!&lt;BR /&gt;I missed that.&lt;BR /&gt; &lt;BR /&gt;2 possibilities:&lt;BR /&gt; &lt;BR /&gt;1. since we are finding whitespace, we *could* just replace it with a single space&lt;BR /&gt; &lt;BR /&gt;sed \&lt;BR /&gt;-e 's/CFG_FILE$/CFG_FILE_TEMP/g' \&lt;BR /&gt;-e 's/CFG_FILE[ ]/CFG_FILE_TEMP /g' &lt;BR /&gt; &lt;BR /&gt;2. better, we could just save the matching character&lt;BR /&gt; &lt;BR /&gt;sed \&lt;BR /&gt;-e 's/CFG_FILE$/CFG_FILE_TEMP/g' \&lt;BR /&gt;-e 's/CFG_FILE\([ ]\)/CFG_FILE_TEMP\1/g'&lt;BR /&gt; &lt;BR /&gt;The \(...\) saves the characters ... and they are "recalled" via \1.&lt;BR /&gt;If you have more than one \(...\) in the match string, they are recalled by occurrence in the replacement string:&lt;BR /&gt; \1  then \2 then \3 , etc.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;bv&lt;BR /&gt;</description>
      <pubDate>Mon, 08 Dec 2003 08:20:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-sed/m-p/3136353#M900735</guid>
      <dc:creator>Bob_Vance</dc:creator>
      <dc:date>2003-12-08T08:20:03Z</dc:date>
    </item>
    <item>
      <title>Re: Using sed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-sed/m-p/3136354#M900736</link>
      <description>I prefer &lt;BR /&gt;perl -p -i -e s/VAR1/VAR2/g &lt;BR /&gt;&lt;BR /&gt;I first set the variables in my script &lt;BR /&gt;&lt;BR /&gt;for example &lt;BR /&gt;export dist=elk&lt;BR /&gt;export train=train &lt;BR /&gt;export fin=fin &lt;BR /&gt;&lt;BR /&gt;perl -p -i -e s/$dist$train/DBNAME/g dropit&lt;BR /&gt;&lt;BR /&gt;where dropit is is an sql script.. &lt;BR /&gt;&lt;BR /&gt;#dropit&lt;BR /&gt;drop database DBNAME&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Works great.. &lt;BR /&gt;&lt;BR /&gt;happy holidays all..</description>
      <pubDate>Mon, 22 Dec 2003 09:10:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-sed/m-p/3136354#M900736</guid>
      <dc:creator>rmueller58</dc:creator>
      <dc:date>2003-12-22T09:10:18Z</dc:date>
    </item>
  </channel>
</rss>

