Re: sed command

  • From: Howard Latham <howard.latham@xxxxxxxxx>
  • To: mhdmehraj@xxxxxxxxx
  • Date: Fri, 15 May 2009 10:22:57 +0100

you can of course suppress almost all the extraneous output from  SQLPLUS

try

SET FEEDBACK 0
SET ECHO 0FF
SET VERIFY OFF

2009/5/15 Mohammed Mehraj hussain <mhdmehraj@xxxxxxxxx>

> hi Michael ,
> Here my scenario is also like that which you have  mentioned bellow.
> this is my entry in the batch file .
> first we are creating the sql commands from a index file , and then we
> are formatting that index file by removing all the rem etc.
>
> imp system/manager file=emp.dmp  fromuser=scott touser=hr
> indexfile=objects.sql log=objects.log 2>&1 | %TEE% -a %LOGFILE%
>
> rem
> -----------------------------------------------------------------------------
> rem format the objects.sql file to obj.sql
> rem
> -----------------------------------------------------------------------------
>
> del obj.sql 2>&1 | %TEE% -a %LOGFILE%
>
> sed "s/REM //" objects.sql | sed "/rows/d"  | sed -e "s/#.*//" -e
> "/^$/ d"  |sed "s/CONNECT %OraSchemaOwner%//"  | sed "1a spool
> obj.log" | sed "$a\ " | sed "$a\  spool off" | sed "$a\ exit;" >>
> obj.sql 2>&1 | %TEE% -a %LOGFILE%
>
>
> my case is in the index file a a command is created like the below one
>
> REM  ALTER TABLE "HR"."EMPLOYEES" MODIFY ("DATE_TIME" DEFAULT
> REM  sysdate
> REM
> REM
> REM
> REM  ) ;
> REM  ... 260000 rows
>
> it is formatting into
>
>  ALTER TABLE "HR"."EMPLOYEES" MODIFY ("DATE_TIME" DEFAULT
>  sysdate
>
>
>
>  ) ;
>
> when this command runs ,it is comming like this
>
>
> SQL> ALTER TABLE "HR"."EMPLOYEES"  MODIFY ("DATE_TIME" DEFAULT
>  2   sysdate
>  3
> SQL>
> SQL>
> SQL>  ) ;
> SP2-0042: unknown command ") " - rest of line ignored.
>
> AND MY REST OF THE COMMANDS IN THE BATCH FILE IS ABORTED..
>
> so i need to include a proper formatting command to ignore the lines
> in-between this one
>
> ALTER TABLE "HR"."EMPLOYEES"  MODIFY ("DATE_TIME" DEFAULT
>  sysdate
>
>
>
>  ) ;
>
> and need to merge with the );
>
>
> plz suggest some commands to do the above task which i need to include in
> this
>
> sed "s/REM //" objects.sql | sed "/rows/d"  | sed -e "s/#.*//" -e
> "/^$/ d"  |sed "s/CONNECT %OraSchemaOwner%//"  | sed "1a spool
> obj.log" | sed "$a\ " | sed "$a\  spool off" | sed "$a\ exit;" >>
> obj.sql 2>&1 | %TEE% -a %LOGFILE%
>
>
> Thanks and Regards,
> Mohammed
>
>
> On Fri, May 15, 2009 at 11:47 AM, Michael Garfield Sørensen
> <mgs@xxxxxxxx> wrote:
> >
> > http://gnuwin32.sourceforge.net/packages/sed.htm = Sed for Windows
> >
> > Works like a charm:
> > ------------------------------------------------------------------
> > Microsoft Windows XP [Version 5.1.2600]
> > (C) Copyright 1985-2001 Microsoft Corp.
> >
> > C:\>type sample.sql
> > REM SELECT * FROM DUAL;
> >
> >
> > C:\>which sed
> > C:\Program Files\GnuWin32\bin\sed.EXE
> >
> > C:\>sed "s/REM //" sample.sql
> > SELECT * FROM DUAL;
> >
> > ------------------------------------------------------------------
> >
> > HTH
> > Michael Garfield Sørensen, CeDeT
> >
> >
> > Quoting Niall Litchfield <niall.litchfield@xxxxxxxxx>:
> >
> >> sed is a unix command line tool. You can get various replacements using
> >> cygwin or others - if sed is a gnu utility there will likely be a
> windows
> >> binary for it, or you can reformulate your problem as a business problem
> >> rather than a technology issue - for example I need to remove all
> >> occurrences of a string from a file, preferably using the command line.
> I'd
> >> just use ctrl-h in write to do string replacement in a text file fwiw.
> >>
> >> Niall
> >>
> >> On Fri, May 15, 2009 at 6:35 AM, Mohammed Mehraj hussain <
> >> mhdmehraj@xxxxxxxxx> wrote:
> >>
> >>> hi all ,
> >>>
> >>> i need to format a file using the sed command on windows .
> >>>
> >>> For example iam running this command in my comman prompt of win xp.
> >>>
> >>> D:\sample> sed "s/REM //" sample.sql
> >>>
> >>> 'sed' is not recognized as an internal or external command,
> >>> operable program or batch file.
> >>>
> >>>
> >>>
> >>>
> >>
> >>
> >> --
> >> Niall Litchfield
> >> Oracle DBA
> >> http://www.orawin.info
> >>
> >
> >
> >
> --
> //www.freelists.org/webpage/oracle-l
>
>
>


-- 
Howard A. Latham

Other related posts: