<?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: sed how to in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-how-to/m-p/2465908#M774355</link>
    <description>Heres a good link for some sed 1 liners&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://www.cornerstonemag.com/sed/sed1line.txt" target="_blank"&gt;http://www.cornerstonemag.com/sed/sed1line.txt&lt;/A&gt;</description>
    <pubDate>Mon, 20 Nov 2000 19:47:29 GMT</pubDate>
    <dc:creator>Tony Constantine_1</dc:creator>
    <dc:date>2000-11-20T19:47:29Z</dc:date>
    <item>
      <title>sed how to</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-how-to/m-p/2465893#M774340</link>
      <description>I need to modify a file in the following manner:&lt;BR /&gt;- remove all blank lines&lt;BR /&gt;- change the last occurance of a comma (,) to a left paren&lt;BR /&gt;&lt;BR /&gt;any ideas</description>
      <pubDate>Mon, 20 Nov 2000 15:37:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-how-to/m-p/2465893#M774340</guid>
      <dc:creator>Roger G. Vincent</dc:creator>
      <dc:date>2000-11-20T15:37:54Z</dc:date>
    </item>
    <item>
      <title>Re: sed how to</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-how-to/m-p/2465894#M774341</link>
      <description>cat file | grep -v '^$' | sed -e 's/,$/(/'</description>
      <pubDate>Mon, 20 Nov 2000 15:48:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-how-to/m-p/2465894#M774341</guid>
      <dc:creator>Lasse Knudsen</dc:creator>
      <dc:date>2000-11-20T15:48:36Z</dc:date>
    </item>
    <item>
      <title>Re: sed how to</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-how-to/m-p/2465895#M774342</link>
      <description>sed -e '/^$/d' -e 's/,$/(/' &lt;FILE&gt;&lt;/FILE&gt;</description>
      <pubDate>Mon, 20 Nov 2000 15:50:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-how-to/m-p/2465895#M774342</guid>
      <dc:creator>Rainer_1</dc:creator>
      <dc:date>2000-11-20T15:50:57Z</dc:date>
    </item>
    <item>
      <title>Re: sed how to</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-how-to/m-p/2465896#M774343</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Is the comma the last character of the line?  If so, then the first two suggestions will work fine.  If you mean the last comma, but not necessarily the last character, try the following:&lt;BR /&gt;&lt;BR /&gt; sed  -e '/^$/d'  -e 's/,[^,]*$/(/'  &lt;FILENAME&gt;&lt;BR /&gt;&lt;BR /&gt;Hope this helps,&lt;BR /&gt;&lt;BR /&gt;Bruce&lt;/FILENAME&gt;</description>
      <pubDate>Mon, 20 Nov 2000 16:07:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-how-to/m-p/2465896#M774343</guid>
      <dc:creator>Bruce Regittko</dc:creator>
      <dc:date>2000-11-20T16:07:54Z</dc:date>
    </item>
    <item>
      <title>Re: sed how to</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-how-to/m-p/2465897#M774344</link>
      <description>Roger, the other 2 posts definetely desirve 10pts for their smooth and "true hack" solutions.</description>
      <pubDate>Mon, 20 Nov 2000 16:24:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-how-to/m-p/2465897#M774344</guid>
      <dc:creator>Lasse Knudsen</dc:creator>
      <dc:date>2000-11-20T16:24:30Z</dc:date>
    </item>
    <item>
      <title>Re: sed how to</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-how-to/m-p/2465898#M774345</link>
      <description>This was close however, I want to change the last occurance of a comma (,) in the file to a paren NOT each occurance of a comma to a paren.</description>
      <pubDate>Mon, 20 Nov 2000 16:26:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-how-to/m-p/2465898#M774345</guid>
      <dc:creator>Roger G. Vincent</dc:creator>
      <dc:date>2000-11-20T16:26:04Z</dc:date>
    </item>
    <item>
      <title>Re: sed how to</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-how-to/m-p/2465899#M774346</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;To change the last occurrence of ',' try the following:-&lt;BR /&gt;&lt;BR /&gt;sed -e '/^$/d' -e 's/\(.*\),\(.*\)/\1(\2/' &lt;FILENAME&gt;&lt;BR /&gt;&lt;BR /&gt;Hope the backslashes appear! there's enough of them.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;John&lt;/FILENAME&gt;</description>
      <pubDate>Mon, 20 Nov 2000 16:36:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-how-to/m-p/2465899#M774346</guid>
      <dc:creator>John Palmer</dc:creator>
      <dc:date>2000-11-20T16:36:35Z</dc:date>
    </item>
    <item>
      <title>Re: sed how to</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-how-to/m-p/2465900#M774347</link>
      <description>Try: cat file |sed -e '/^$/d' -e 's/\(.*\),\(.*\)/\1(\2/' &amp;gt; newfile&lt;BR /&gt; &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 20 Nov 2000 16:46:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-how-to/m-p/2465900#M774347</guid>
      <dc:creator>CHRIS_ANORUO</dc:creator>
      <dc:date>2000-11-20T16:46:50Z</dc:date>
    </item>
    <item>
      <title>Re: sed how to</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-how-to/m-p/2465901#M774348</link>
      <description>The commas are killing me.  I have a file with multiple lines which end with a comma (,).  I need to change the very last comma of the file to a right paren ")".  I am sorry for the confusion, however, I stated the question improperly (or at least it was unclear).  I am new to this point value stuff and I appreciate all responses and will get the points right soon.</description>
      <pubDate>Mon, 20 Nov 2000 16:50:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-how-to/m-p/2465901#M774348</guid>
      <dc:creator>Roger G. Vincent</dc:creator>
      <dc:date>2000-11-20T16:50:57Z</dc:date>
    </item>
    <item>
      <title>Re: sed how to</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-how-to/m-p/2465902#M774349</link>
      <description>Hi Rogers, &lt;BR /&gt;&lt;BR /&gt;Check this very well and run into another file as indicated: cat filename |sed -e '/^$/d' -e 's/\(.*\),\(.*\)/\1)\2/' &amp;gt; newfilename</description>
      <pubDate>Mon, 20 Nov 2000 16:58:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-how-to/m-p/2465902#M774349</guid>
      <dc:creator>CHRIS_ANORUO</dc:creator>
      <dc:date>2000-11-20T16:58:13Z</dc:date>
    </item>
    <item>
      <title>Re: sed how to</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-how-to/m-p/2465903#M774350</link>
      <description>the command cat filename | sed -e '/^$/d' -e 's/\(.*\),\(.*\)/\1)\2/' &amp;gt; newfilename appears to change ALL occurances of the , at the end of a line to a right paren.  I want to change the LAST comma of the file to a right paren and preserve the remaining commas on all other lines in the file.</description>
      <pubDate>Mon, 20 Nov 2000 17:45:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-how-to/m-p/2465903#M774350</guid>
      <dc:creator>Roger G. Vincent</dc:creator>
      <dc:date>2000-11-20T17:45:08Z</dc:date>
    </item>
    <item>
      <title>Re: sed how to</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-how-to/m-p/2465904#M774351</link>
      <description>Hi Roger,&lt;BR /&gt;&lt;BR /&gt;This one works for sure:&lt;BR /&gt;&lt;BR /&gt;sed -e '/^$/d' -e 's/\(,\)\([^,]*$\)/)\2/' &amp;lt; infile&lt;BR /&gt;&lt;BR /&gt;Explanation:&lt;BR /&gt;&lt;BR /&gt;/^$/d  deletes empty lines&lt;BR /&gt;s/\(,\)\([^,]*$\)/)\2/ substitutes a comma (1st matching item) followed by 0 or more non-commas up to the end of line (2nd matching item) by a right paren followed by the 2nd match item &lt;BR /&gt;&lt;BR /&gt;Matching Items are delimited by \( and \) in the search string&lt;BR /&gt;&lt;BR /&gt;Best regards,&lt;BR /&gt;&lt;BR /&gt;Dan&lt;BR /&gt;</description>
      <pubDate>Mon, 20 Nov 2000 17:50:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-how-to/m-p/2465904#M774351</guid>
      <dc:creator>Dan Hetzel</dc:creator>
      <dc:date>2000-11-20T17:50:56Z</dc:date>
    </item>
    <item>
      <title>Re: sed how to</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-how-to/m-p/2465905#M774352</link>
      <description>Maybe it is me, however the last command did NOT work...It changed each line with a trailing comma to a right paren.  I have the following input data:&lt;BR /&gt;&lt;BR /&gt;This is first line,&lt;BR /&gt;This is second line,&lt;BR /&gt;This is the last line,&lt;BR /&gt;&lt;BR /&gt;I want to leave commas on first and second line alone and change the comma on the last line to a right paren ).&lt;BR /&gt;&lt;BR /&gt;Solution should be:&lt;BR /&gt;This is first line,&lt;BR /&gt;This is second line,&lt;BR /&gt;This is the last line)</description>
      <pubDate>Mon, 20 Nov 2000 19:08:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-how-to/m-p/2465905#M774352</guid>
      <dc:creator>Roger G. Vincent</dc:creator>
      <dc:date>2000-11-20T19:08:45Z</dc:date>
    </item>
    <item>
      <title>Re: sed how to</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-how-to/m-p/2465906#M774353</link>
      <description>You may need to use awk instead.  Are all of the lines 3 long?&lt;BR /&gt;line1,&lt;BR /&gt;line2,&lt;BR /&gt;line3)&lt;BR /&gt;or is there a variety?  Many files, or just one short one?&lt;BR /&gt;awk can use the same sed commands, but you have the ability to count, track record numbers, etc....&lt;BR /&gt;</description>
      <pubDate>Mon, 20 Nov 2000 19:19:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-how-to/m-p/2465906#M774353</guid>
      <dc:creator>Shannon Petry</dc:creator>
      <dc:date>2000-11-20T19:19:01Z</dc:date>
    </item>
    <item>
      <title>Re: sed how to</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-how-to/m-p/2465907#M774354</link>
      <description>think now it's time for awk.&lt;BR /&gt;try this&lt;BR /&gt;&lt;BR /&gt;awk 'BEGIN{&lt;BR /&gt;line="";}&lt;BR /&gt;{&lt;BR /&gt;if(length($0)==0)continue;&lt;BR /&gt;if(length(line)&amp;gt;0)print line;&lt;BR /&gt;line=$0;&lt;BR /&gt;}&lt;BR /&gt;END{&lt;BR /&gt;sub(",$",")",line);&lt;BR /&gt;print line;&lt;BR /&gt;}' &lt;FILE&gt;&lt;/FILE&gt;</description>
      <pubDate>Mon, 20 Nov 2000 19:38:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-how-to/m-p/2465907#M774354</guid>
      <dc:creator>Rainer_1</dc:creator>
      <dc:date>2000-11-20T19:38:38Z</dc:date>
    </item>
    <item>
      <title>Re: sed how to</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-how-to/m-p/2465908#M774355</link>
      <description>Heres a good link for some sed 1 liners&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://www.cornerstonemag.com/sed/sed1line.txt" target="_blank"&gt;http://www.cornerstonemag.com/sed/sed1line.txt&lt;/A&gt;</description>
      <pubDate>Mon, 20 Nov 2000 19:47:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-how-to/m-p/2465908#M774355</guid>
      <dc:creator>Tony Constantine_1</dc:creator>
      <dc:date>2000-11-20T19:47:29Z</dc:date>
    </item>
    <item>
      <title>Re: sed how to</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-how-to/m-p/2465909#M774356</link>
      <description>As long as there aren't any blank lines at the end of the file, you got it, Ranier. I thought about using 'tac' ('cat' the file backwards) to reverse the input, search for and replace  the FIRST occurrence of ",$", then 'tac' the file again to get it back in the right order--but HP-UX doesn't have a 'tac.' So much for quick-and-dirty.</description>
      <pubDate>Mon, 20 Nov 2000 22:02:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-how-to/m-p/2465909#M774356</guid>
      <dc:creator>Kevin Ernst</dc:creator>
      <dc:date>2000-11-20T22:02:39Z</dc:date>
    </item>
    <item>
      <title>Re: sed how to</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-how-to/m-p/2465910#M774357</link>
      <description>Doh! RaInEr--sorry.</description>
      <pubDate>Mon, 20 Nov 2000 22:05:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-how-to/m-p/2465910#M774357</guid>
      <dc:creator>Kevin Ernst</dc:creator>
      <dc:date>2000-11-20T22:05:46Z</dc:date>
    </item>
    <item>
      <title>Re: sed how to</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-how-to/m-p/2465911#M774358</link>
      <description>Kevin, Roger,&lt;BR /&gt;&lt;BR /&gt;We don't have 'tac' but we have 'rev' which prints every line backwards&lt;BR /&gt;&lt;BR /&gt;one solution could be:&lt;BR /&gt;&lt;BR /&gt;rev infile | sed -e '/^$/d -e '$s/,/)/' | rev &amp;gt; outputfile&lt;BR /&gt;&lt;BR /&gt;or  &lt;BR /&gt;&lt;BR /&gt;sed -e '/^$/d' &amp;lt; infile | sed -e '$s/\(,\)\([^,]*$\)/)\2/'&lt;BR /&gt;&lt;BR /&gt;will both replace the last comma of the last non blank line by a right paren, even if it's not the last character on the line,providing there is a comma on that line.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Dan&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 21 Nov 2000 06:35:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-how-to/m-p/2465911#M774358</guid>
      <dc:creator>Dan Hetzel</dc:creator>
      <dc:date>2000-11-21T06:35:26Z</dc:date>
    </item>
  </channel>
</rss>

