<?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 on Line Selection in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-on-line-selection/m-p/3597733#M829477</link>
    <description>I would agree with Schulz's solution with slight modifications. Create a shell script as follows and run it at the command line:&lt;BR /&gt;&lt;BR /&gt;=============================================&lt;BR /&gt;# sqlplus -s &lt;USERNAME&gt;/&lt;PASSWORD&gt;@&lt;INSTANCE&gt; &amp;lt;&lt;EOF&gt;&lt;/EOF&gt;set head on feed off echo off&lt;BR /&gt;spool filename.out&lt;BR /&gt;select tablespace_name,sum(bytes) free from dba_free_space group by tablespace_name&lt;BR /&gt;/&lt;BR /&gt;spool off&lt;BR /&gt;exit&lt;BR /&gt;EOF&lt;BR /&gt;=============================================&lt;BR /&gt;&lt;BR /&gt;cheers!&lt;/INSTANCE&gt;&lt;/PASSWORD&gt;&lt;/USERNAME&gt;</description>
    <pubDate>Mon, 08 Aug 2005 12:22:23 GMT</pubDate>
    <dc:creator>Sandman!</dc:creator>
    <dc:date>2005-08-08T12:22:23Z</dc:date>
    <item>
      <title>Script Help on Line Selection</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-on-line-selection/m-p/3597727#M829471</link>
      <description>I would like to get advise on how to get certain lines in the whole sql result, e.g.&lt;BR /&gt;&lt;BR /&gt;==================================&lt;BR /&gt;&lt;BR /&gt;SQL&amp;gt; select tablespace_name,sum(bytes) free from dba_free_space group by tablesp&lt;BR /&gt;ace_name;&lt;BR /&gt;TABLESPACE_NAME                      FREE&lt;BR /&gt;------------------------------ ----------&lt;BR /&gt;DRSYS                            16637952&lt;BR /&gt;INDX                             20963328&lt;BR /&gt;PRODDATA                       2791825408&lt;BR /&gt;PRODINDEX                       592568320&lt;BR /&gt;RBS                             633856000&lt;BR /&gt;SYSTEM                          318390272&lt;BR /&gt;TEMP                           1048567808&lt;BR /&gt;TOOLS                             5234688&lt;BR /&gt;USERS                            65265664&lt;BR /&gt;&lt;BR /&gt;9 rows selected.&lt;BR /&gt;==========================================&lt;BR /&gt;&lt;BR /&gt;if I cat the spool file, I have all lines.   How to only get the lines without head and tail, or only for tablespace_name listings like:&lt;BR /&gt;&lt;BR /&gt;TABLESPACE_NAME                      FREE&lt;BR /&gt;------------------------------ ----------&lt;BR /&gt;DRSYS                            16637952&lt;BR /&gt;INDX                             20963328&lt;BR /&gt;PRODDATA                       2791825408&lt;BR /&gt;PRODINDEX                       592568320&lt;BR /&gt;RBS                             633856000&lt;BR /&gt;SYSTEM                          318390272&lt;BR /&gt;TEMP                           1048567808&lt;BR /&gt;TOOLS                             5234688&lt;BR /&gt;USERS                            65265664&lt;BR /&gt;&lt;BR /&gt;Any help is appreciated.   &lt;BR /&gt;&lt;BR /&gt;Steven</description>
      <pubDate>Fri, 05 Aug 2005 15:54:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-on-line-selection/m-p/3597727#M829471</guid>
      <dc:creator>Steven Chen_1</dc:creator>
      <dc:date>2005-08-05T15:54:20Z</dc:date>
    </item>
    <item>
      <title>Re: Script Help on Line Selection</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-on-line-selection/m-p/3597728#M829472</link>
      <description>for simplicity, let's assume you directed this output to a file and exit out of the sql&amp;gt; prompt. You are at the unix command prompt.&lt;BR /&gt;&lt;BR /&gt;assuming first line you want is the &lt;BR /&gt;&lt;BR /&gt;TABLESPACE_NAME FREE&lt;BR /&gt;&lt;BR /&gt;and you do not want including line &lt;BR /&gt;&lt;BR /&gt;9 rows selected &lt;BR /&gt;&lt;BR /&gt;and anything after that&lt;BR /&gt;&lt;BR /&gt;# you placed the sql output is in outfile&lt;BR /&gt;(( startline=`grep -n TABLESPACE_NAME outfile | cut -d: -f1` - 1 ))&lt;BR /&gt;sed -e "1,${startline}d" outfile &amp;gt;interimfile&lt;BR /&gt;endline=`grep -n "rows selected" outfile | cut -d: -f1`&lt;BR /&gt;sed -e "${endline},\$d" outfile | sed -e "1,${startline}d" &amp;gt; final_output&lt;BR /&gt;&lt;BR /&gt;you can use command substitutions and combine all these 3 lines into one, gigantic, ugly sed command but I preferred to put it down this way, so what I was telling was obvious.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Hope this helps</description>
      <pubDate>Fri, 05 Aug 2005 17:09:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-on-line-selection/m-p/3597728#M829472</guid>
      <dc:creator>Mel Burslan</dc:creator>
      <dc:date>2005-08-05T17:09:49Z</dc:date>
    </item>
    <item>
      <title>Re: Script Help on Line Selection</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-on-line-selection/m-p/3597729#M829473</link>
      <description>sorry, the interimfile line should not have existed. correct script is as follows:&lt;BR /&gt;&lt;BR /&gt;(( startline=`grep -n TABLESPACE_NAME outfile | cut -d: -f1` - 1 ))&lt;BR /&gt;endline=`grep -n "rows selected" outfile | cut -d: -f1`&lt;BR /&gt;sed -e "${endline},\$d" outfile | sed -e "1,${startline}d" &amp;gt; final_output&lt;BR /&gt;</description>
      <pubDate>Fri, 05 Aug 2005 17:11:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-on-line-selection/m-p/3597729#M829473</guid>
      <dc:creator>Mel Burslan</dc:creator>
      <dc:date>2005-08-05T17:11:52Z</dc:date>
    </item>
    <item>
      <title>Re: Script Help on Line Selection</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-on-line-selection/m-p/3597730#M829474</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;i would suggest not to filter the output but to configure everything so that only the desired lines are in the output. Thats much easier to maintain.&lt;BR /&gt;&lt;BR /&gt;If you use some Oracle set commands you can configure your output pretty easy.&lt;BR /&gt;&lt;BR /&gt;For example this will give you a report without the command itselve, and without the sql feedback (xx rows selected).&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;set NEWPAGE 0;&lt;BR /&gt;set PAGESIZE 0;&lt;BR /&gt;set LINESIZE 560;&lt;BR /&gt;set COLSEP '';&lt;BR /&gt;set FEEDBACK OFF;&lt;BR /&gt;set HEADING OFF;&lt;BR /&gt;SET ECHO OFF;&lt;BR /&gt;set VERIFY OFF;&lt;BR /&gt;set TERMOUT OFF;&lt;BR /&gt;&lt;BR /&gt;spool &lt;YOUR outputfile=""&gt;;&lt;BR /&gt;&lt;BR /&gt;SELECT &lt;YOUR select="" statement=""&gt;;&lt;BR /&gt;&lt;BR /&gt;spool off;&lt;BR /&gt;quit;&lt;BR /&gt;&lt;BR /&gt;Put this in a script and give it a try. You might want to set HEADING to ON. But the rest should be pretty close to what you need.&lt;BR /&gt;&lt;BR /&gt;Hope this helps&lt;BR /&gt;&lt;BR /&gt;Regards Stefan&lt;/YOUR&gt;&lt;/YOUR&gt;</description>
      <pubDate>Mon, 08 Aug 2005 02:22:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-on-line-selection/m-p/3597730#M829474</guid>
      <dc:creator>Stefan Schulz</dc:creator>
      <dc:date>2005-08-08T02:22:30Z</dc:date>
    </item>
    <item>
      <title>Re: Script Help on Line Selection</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-on-line-selection/m-p/3597731#M829475</link>
      <description>You can do it as,&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#!/bin/ksh&lt;BR /&gt;SPOOL=test.log&lt;BR /&gt;line=$(wc -l $SPOOL)&lt;BR /&gt;let end=$line-2&lt;BR /&gt;start=$(grep -n ";" ${SPOOL} | cut -d":" -f1)&lt;BR /&gt;sed -e "$start,$end !d" $SPOOL&lt;BR /&gt;&lt;BR /&gt;hth.&lt;BR /&gt;</description>
      <pubDate>Mon, 08 Aug 2005 03:33:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-on-line-selection/m-p/3597731#M829475</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2005-08-08T03:33:15Z</dc:date>
    </item>
    <item>
      <title>Re: Script Help on Line Selection</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-on-line-selection/m-p/3597732#M829476</link>
      <description>I'm with Stefan: Best prevent the undesired data lines.&lt;BR /&gt;But if you have several files with then already then you could use the following 'cleanup' perl one-liner&lt;BR /&gt;&lt;BR /&gt;perl -e 'while (&amp;lt;&amp;gt;) { $x++ if /^---/; $x-- if /rows select/;print $line if&lt;BR /&gt;$x; $line=$_}  &amp;lt; old.txt &amp;gt; new.txt&lt;BR /&gt;&lt;BR /&gt;This remembers a prior line in $line.&lt;BR /&gt;It looks at the current like whether to start or stop printing that prior line.&lt;BR /&gt;&lt;BR /&gt;fwiw,&lt;BR /&gt;&lt;BR /&gt;Hein.&lt;BR /&gt;</description>
      <pubDate>Mon, 08 Aug 2005 04:58:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-on-line-selection/m-p/3597732#M829476</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2005-08-08T04:58:36Z</dc:date>
    </item>
    <item>
      <title>Re: Script Help on Line Selection</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-on-line-selection/m-p/3597733#M829477</link>
      <description>I would agree with Schulz's solution with slight modifications. Create a shell script as follows and run it at the command line:&lt;BR /&gt;&lt;BR /&gt;=============================================&lt;BR /&gt;# sqlplus -s &lt;USERNAME&gt;/&lt;PASSWORD&gt;@&lt;INSTANCE&gt; &amp;lt;&lt;EOF&gt;&lt;/EOF&gt;set head on feed off echo off&lt;BR /&gt;spool filename.out&lt;BR /&gt;select tablespace_name,sum(bytes) free from dba_free_space group by tablespace_name&lt;BR /&gt;/&lt;BR /&gt;spool off&lt;BR /&gt;exit&lt;BR /&gt;EOF&lt;BR /&gt;=============================================&lt;BR /&gt;&lt;BR /&gt;cheers!&lt;/INSTANCE&gt;&lt;/PASSWORD&gt;&lt;/USERNAME&gt;</description>
      <pubDate>Mon, 08 Aug 2005 12:22:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-on-line-selection/m-p/3597733#M829477</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2005-08-08T12:22:23Z</dc:date>
    </item>
    <item>
      <title>Re: Script Help on Line Selection</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-on-line-selection/m-p/3597734#M829478</link>
      <description>Stefan's is about the best, except I'd make one modification: (Stefan, I'm "bumming" your steps to mod - hope that's OK).  This will keep your select statement from showing up in the spooled output.&lt;BR /&gt;&lt;BR /&gt;Put your select statement in the buffer (and leave it there) BEFORE doing your spool command.  Then, put in the spool command, then just do a "/" to run the select. Put a "spool off" immediately after the select runs.  This gives a pretty clean output, suitable for sending to lpt once you've played with the newpage, pagesize, etc.&lt;BR /&gt;&lt;BR /&gt;Also call sqlplus in SILENT mode (-S).&lt;BR /&gt;&lt;BR /&gt;set NEWPAGE 0&lt;BR /&gt;set PAGESIZE 0&lt;BR /&gt;set LINESIZE 560&lt;BR /&gt;set COLSEP ''&lt;BR /&gt;set FEEDBACK OFF&lt;BR /&gt;set HEADING OFF&lt;BR /&gt;SET ECHO OFF&lt;BR /&gt;set VERIFY OFF&lt;BR /&gt;set TERMOUT OFF&lt;BR /&gt;&lt;BR /&gt;SELECT &lt;YOUR select="" statement=""&gt;&lt;BR /&gt;spool &lt;YOUR outputfile=""&gt;&lt;BR /&gt;/&lt;BR /&gt;spool off&lt;BR /&gt;quit;&lt;/YOUR&gt;&lt;/YOUR&gt;</description>
      <pubDate>Mon, 08 Aug 2005 16:48:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-on-line-selection/m-p/3597734#M829478</guid>
      <dc:creator>TwoProc</dc:creator>
      <dc:date>2005-08-08T16:48:37Z</dc:date>
    </item>
    <item>
      <title>Re: Script Help on Line Selection</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-on-line-selection/m-p/3597735#M829479</link>
      <description>I think the below script will solve the problem.&lt;BR /&gt;&lt;BR /&gt;lists.lst : This will have the tablespace details.&lt;BR /&gt;&lt;BR /&gt;cat lists.lst | grep -v "rows selected" | grep -v "TABLESPACE_NAME" | grep -v "-"&lt;BR /&gt;&lt;BR /&gt;After executing the above commnad you will get only the table space names.&lt;BR /&gt;&lt;BR /&gt;-- Venkatesh</description>
      <pubDate>Tue, 09 Aug 2005 02:19:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-on-line-selection/m-p/3597735#M829479</guid>
      <dc:creator>Venkatesh_18</dc:creator>
      <dc:date>2005-08-09T02:19:54Z</dc:date>
    </item>
    <item>
      <title>Re: Script Help on Line Selection</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-on-line-selection/m-p/3597736#M829480</link>
      <description>appreciate everyone jumping in to help.&lt;BR /&gt;&lt;BR /&gt;By far, I find 2 solutions that are simply and workable:&lt;BR /&gt;&lt;BR /&gt;1) sql coding....&lt;BR /&gt;   spool xxx&lt;BR /&gt;   /&lt;BR /&gt;&lt;BR /&gt;  so that it does not show the sqlcode.&lt;BR /&gt;&lt;BR /&gt;2) sed -n 3,10p /tmp/xxx.lst&lt;BR /&gt;&lt;BR /&gt;Again, this is a great forum from where you  brain stormed and try all ways for a fix.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 09 Aug 2005 10:22:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-on-line-selection/m-p/3597736#M829480</guid>
      <dc:creator>Steven Chen_1</dc:creator>
      <dc:date>2005-08-09T10:22:50Z</dc:date>
    </item>
  </channel>
</rss>

