Re: sed command
Date: Fri, 15 May 2009 10:20:15 +0200
Message-ID: <20090515102015.bmgbcplz40wogwks_at_webmail.cedet.dk>
You can remove the "empty" REM-lines before sed'ing:
grep -v "^REM *$" objects.sql | sed "s/REM //" | ...
You need grep (or similar) for that (for example http://gnuwin32.sourceforge.net/packages/grep.htm = Grep for Windows)
Seems to me you may want to look into cygwin OR change to Unix OR go the alternate route of Windows Script(ing) - http://www.microsoft.com/technet/scriptcenter/default.mspx
HTH
Michael Garfield Sørensen, CeDeT
Quoting Mohammed Mehraj hussain <mhdmehraj_at_gmail.com>:
> 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
> ...
-- http://www.freelists.org/webpage/oracle-lReceived on Fri May 15 2009 - 03:20:15 CDT