<?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: previous line in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/previous-line/m-p/3159951#M159201</link>
    <description>If you want, it can even be done with a shell script:&lt;BR /&gt;grep -n connected &lt;FILE&gt; | cut -d: -f1 | while read number&lt;BR /&gt;do&lt;BR /&gt;(( number=number-1 ))&lt;BR /&gt;sed -n "${number}p" &lt;FILE&gt;&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;You could even use tail and head to get the line you want.&lt;/FILE&gt;&lt;/FILE&gt;</description>
    <pubDate>Fri, 09 Jan 2004 02:00:15 GMT</pubDate>
    <dc:creator>Elmar P. Kolkman</dc:creator>
    <dc:date>2004-01-09T02:00:15Z</dc:date>
    <item>
      <title>previous line</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/previous-line/m-p/3159947#M159197</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I want to grep the line which contains word "connected" and print previous line.Any help is appreciated.&lt;BR /&gt;&lt;BR /&gt;Thanks.</description>
      <pubDate>Thu, 08 Jan 2004 14:58:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/previous-line/m-p/3159947#M159197</guid>
      <dc:creator>SAM_24</dc:creator>
      <dc:date>2004-01-08T14:58:38Z</dc:date>
    </item>
    <item>
      <title>Re: previous line</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/previous-line/m-p/3159948#M159198</link>
      <description>SAM,&lt;BR /&gt;&lt;BR /&gt;Here's a solution from the "Handy One-Liners for Sed" (attached):&lt;BR /&gt;&lt;BR /&gt;# print 1 line of context before and after regexp, with line number&lt;BR /&gt; # indicating where the regexp occurred (similar to "grep -A1 -B1")&lt;BR /&gt; sed -n -e '/regexp/{=;x;1!p;g;$!N;p;D;}' -e h&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Pete</description>
      <pubDate>Thu, 08 Jan 2004 15:03:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/previous-line/m-p/3159948#M159198</guid>
      <dc:creator>Pete Randall</dc:creator>
      <dc:date>2004-01-08T15:03:28Z</dc:date>
    </item>
    <item>
      <title>Re: previous line</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/previous-line/m-p/3159949#M159199</link>
      <description>If you get the GNU grep command, it has an option "-B num" to print "num" lines before each line.&lt;BR /&gt; &lt;BR /&gt;HTH&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Thu, 08 Jan 2004 16:12:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/previous-line/m-p/3159949#M159199</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2004-01-08T16:12:12Z</dc:date>
    </item>
    <item>
      <title>Re: previous line</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/previous-line/m-p/3159950#M159200</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;something with awk:&lt;BR /&gt;BEGIN{ll="no previous line";}&lt;BR /&gt;  /connect/ {print ll;print $0}&lt;BR /&gt;  {ll=$0;}&lt;BR /&gt;END{}&lt;BR /&gt;&lt;BR /&gt;use awk -f yourname.awk yourfile&lt;BR /&gt;&lt;BR /&gt;greetings,&lt;BR /&gt;&lt;BR /&gt;Michael&lt;BR /&gt;</description>
      <pubDate>Thu, 08 Jan 2004 16:18:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/previous-line/m-p/3159950#M159200</guid>
      <dc:creator>Michael Schulte zur Sur</dc:creator>
      <dc:date>2004-01-08T16:18:19Z</dc:date>
    </item>
    <item>
      <title>Re: previous line</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/previous-line/m-p/3159951#M159201</link>
      <description>If you want, it can even be done with a shell script:&lt;BR /&gt;grep -n connected &lt;FILE&gt; | cut -d: -f1 | while read number&lt;BR /&gt;do&lt;BR /&gt;(( number=number-1 ))&lt;BR /&gt;sed -n "${number}p" &lt;FILE&gt;&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;You could even use tail and head to get the line you want.&lt;/FILE&gt;&lt;/FILE&gt;</description>
      <pubDate>Fri, 09 Jan 2004 02:00:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/previous-line/m-p/3159951#M159201</guid>
      <dc:creator>Elmar P. Kolkman</dc:creator>
      <dc:date>2004-01-09T02:00:15Z</dc:date>
    </item>
    <item>
      <title>Re: previous line</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/previous-line/m-p/3159952#M159202</link>
      <description>Neater solution using shell:&lt;BR /&gt;grep -n connected &lt;FILE&gt; | cut -d: -f1 | while read number&lt;BR /&gt;do&lt;BR /&gt;(( number=number-1 ))&lt;BR /&gt;echo "${number}p" &lt;BR /&gt;done | ed - &lt;FILE&gt;&lt;BR /&gt;&lt;BR /&gt;This way the file is opened twice instead of 1 plus the number of occurrences...&lt;/FILE&gt;&lt;/FILE&gt;</description>
      <pubDate>Fri, 09 Jan 2004 02:15:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/previous-line/m-p/3159952#M159202</guid>
      <dc:creator>Elmar P. Kolkman</dc:creator>
      <dc:date>2004-01-09T02:15:37Z</dc:date>
    </item>
  </channel>
</rss>

