<?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: Script help...awk in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/script-help-awk/m-p/5004428#M98531</link>
    <description>Hi,&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;end=`grep -n linec file | awk -F':' '{print $1}'`&lt;BR /&gt;start=`expr $end - 1`&lt;BR /&gt;sed -n '$start,$endp' file&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;or better:&lt;BR /&gt;get gnu grep and do:&lt;BR /&gt;grep -B1 linec</description>
    <pubDate>Wed, 20 Sep 2006 10:33:12 GMT</pubDate>
    <dc:creator>Peter Godron</dc:creator>
    <dc:date>2006-09-20T10:33:12Z</dc:date>
    <item>
      <title>Script help...awk</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-help-awk/m-p/5004426#M98529</link>
      <description>How can I grep on a line in a file and then print/get the line above it?&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;&lt;BR /&gt;IE:&lt;BR /&gt;&lt;BR /&gt;linea&lt;BR /&gt;lineb&lt;BR /&gt;linec&lt;BR /&gt;lined&lt;BR /&gt;&lt;BR /&gt;grep linec | awk print linec and lineb</description>
      <pubDate>Wed, 20 Sep 2006 10:20:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-help-awk/m-p/5004426#M98529</guid>
      <dc:creator>Coolmar</dc:creator>
      <dc:date>2006-09-20T10:20:20Z</dc:date>
    </item>
    <item>
      <title>Re: Script help...awk</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-help-awk/m-p/5004427#M98530</link>
      <description>cat file | while read line&lt;BR /&gt;do&lt;BR /&gt;grep "string" $line 1&amp;gt;/dev/null 2&amp;gt;/dev/null&lt;BR /&gt;if [ $? -eq 0 ]&lt;BR /&gt;then&lt;BR /&gt;echo ${lastline} &lt;BR /&gt;echo ${line}&lt;BR /&gt;fi&lt;BR /&gt;lastline=${line}&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;I know there is a bug if the string comes on the first line.  I can not think of a solution for it. May be the perl masters will give you a good colution.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Kaps</description>
      <pubDate>Wed, 20 Sep 2006 10:24:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-help-awk/m-p/5004427#M98530</guid>
      <dc:creator>KapilRaj</dc:creator>
      <dc:date>2006-09-20T10:24:31Z</dc:date>
    </item>
    <item>
      <title>Re: Script help...awk</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-help-awk/m-p/5004428#M98531</link>
      <description>Hi,&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;end=`grep -n linec file | awk -F':' '{print $1}'`&lt;BR /&gt;start=`expr $end - 1`&lt;BR /&gt;sed -n '$start,$endp' file&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;or better:&lt;BR /&gt;get gnu grep and do:&lt;BR /&gt;grep -B1 linec</description>
      <pubDate>Wed, 20 Sep 2006 10:33:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-help-awk/m-p/5004428#M98531</guid>
      <dc:creator>Peter Godron</dc:creator>
      <dc:date>2006-09-20T10:33:12Z</dc:date>
    </item>
    <item>
      <title>Re: Script help...awk</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-help-awk/m-p/5004429#M98532</link>
      <description>Hi Coolmar,&lt;BR /&gt;&lt;BR /&gt;# cat file&lt;BR /&gt;linea&lt;BR /&gt;lineb&lt;BR /&gt;linec&lt;BR /&gt;lined&lt;BR /&gt;&lt;BR /&gt;# awk '/linec/{print x; print};{x=$0}' file&lt;BR /&gt;lineb&lt;BR /&gt;linec&lt;BR /&gt;&lt;BR /&gt;PCS</description>
      <pubDate>Wed, 20 Sep 2006 10:36:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-help-awk/m-p/5004429#M98532</guid>
      <dc:creator>spex</dc:creator>
      <dc:date>2006-09-20T10:36:00Z</dc:date>
    </item>
    <item>
      <title>Re: Script help...awk</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-help-awk/m-p/5004430#M98533</link>
      <description>Thanks folks!</description>
      <pubDate>Wed, 20 Sep 2006 10:42:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-help-awk/m-p/5004430#M98533</guid>
      <dc:creator>Coolmar</dc:creator>
      <dc:date>2006-09-20T10:42:30Z</dc:date>
    </item>
  </channel>
</rss>

