![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| find pattern, delete line with pattern and line above and line below | nickg | Shell Programming and Scripting | 4 | 01-29-2009 01:38 PM |
| find pattern delete line with pattern and line above and line below | nickg | UNIX for Dummies Questions & Answers | 1 | 01-28-2009 06:46 PM |
| comment/delete a particular pattern starting from second line of the matching pattern | imas | Shell Programming and Scripting | 4 | 10-13-2008 02:37 AM |
| modify a particular pattern starting from second line of the search pattern | imas | UNIX for Dummies Questions & Answers | 1 | 10-12-2008 01:19 PM |
| need for loop to include fields as one line | prkfriryce | Shell Programming and Scripting | 8 | 03-23-2007 12:49 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Include Line Before Pattern Using Sed / Awk
Hi,
I have a sql file that runs something like this vi Test.sql REVOKE EXECUTE ON DEMO_USER.SQC_SAMP FROM PUBLIC; REVOKE EXECUTE ON DEMO_USER.SQC_SAMP FROM DEMO_READ; REVOKE SELECT ON DEMO_USER.DEMO_NOMINEE_TEST FROM DEMO_READ; REVOKE EXECUTE ON DEMO_USER.SQC_SAMP FROM DEMO_APP_RL; REVOKE SELECT ON DEMO_USER.DEMO_NOMINEE_TEST FROM DEMO_APP_RL; Prompt Drop SYNONYM DEMO_NEWS; DROP SYNONYM DEMO_USER.DEMO_NEWS; Prompt drop View DEMO_NOMINEE_TEST; DROP VIEW DEMO_USER.DEMO_NOMINEE_TEST; Prompt drop Function SQC_SAMP; DROP FUNCTION DEMO_USER.SQC_SAMP; Prompt Type DEMO_ID_REC; -- Difference Details : -- Actual Compared # of Uppercase Lowercase White Other -- Length Length Lines Letters Letters Space Chars -- ****************************************************************** -- Comp * 99 72 5 13 40 26 20 * -- Ref * 132 97 7 32 40 34 26 * -- ****************************************************************** Prompt Type DEMO_ID_REC; -- -- DEMO_ID_REC (Type) -- -- Dependencies: -- STANDARD (Package) -- CREATE TYPE DEMO_USER.DEMO_id_rec AS OBJECT ( LINK_ID varchar2(12), DEMO_ID varchar2(50), SAMPLE_FLG CHAR(1) ) / SHOW ERRORS; Prompt Type STRINGTABLETYPE; -- -- STRINGTABLETYPE (Type) -- -- Dependencies: -- STANDARD (Package) -- CREATE OR REPLACE TYPE DEMO_USER."STRINGTABLETYPE" AS TABLE OF VARCHAR2 (255) / SHOW ERRORS; Basically the Script must look for All Lines that have either CREATE TYPE / CREATE OR REPLACE TYPE and must pick the type name which is usually 3rd Word for Lines with CREATE TYPE TYPENAME and 5th word for lines containing CREATE OR REPLACE TYPE TYPENAME The script must generated a DROP TYPE TYPENAME FORCE; and Place this DROP Command just before the CREATE / CREATE OR REPLACE Type commands. Like in the above case the expected outcome is vi out.sql REVOKE EXECUTE ON DEMO_USER.SQC_SAMP FROM PUBLIC; REVOKE EXECUTE ON DEMO_USER.SQC_SAMP FROM DEMO_READ; REVOKE SELECT ON DEMO_USER.DEMO_NOMINEE_TEST FROM DEMO_READ; REVOKE EXECUTE ON DEMO_USER.SQC_SAMP FROM DEMO_APP_RL; REVOKE SELECT ON DEMO_USER.DEMO_NOMINEE_TEST FROM DEMO_APP_RL; Prompt Drop SYNONYM DEMO_NEWS; DROP SYNONYM DEMO_USER.DEMO_NEWS; Prompt drop View DEMO_NOMINEE_TEST; DROP VIEW DEMO_USER.DEMO_NOMINEE_TEST; Prompt drop Function SQC_SAMP; DROP FUNCTION DEMO_USER.SQC_SAMP; Prompt Type DEMO_ID_REC; -- Difference Details : -- Actual Compared # of Uppercase Lowercase White Other -- Length Length Lines Letters Letters Space Chars -- ****************************************************************** -- Comp * 99 72 5 13 40 26 20 * -- Ref * 132 97 7 32 40 34 26 * -- ****************************************************************** Prompt Type DEMO_ID_REC; -- -- DEMO_ID_REC (Type) -- -- Dependencies: -- STANDARD (Package) -- DROP TYPE DEMO_USER.DEMO_id_rec FORCE; CREATE TYPE DEMO_USER.DEMO_id_rec AS OBJECT ( LINK_ID varchar2(12), DEMO_ID varchar2(50), SAMPLE_FLG CHAR(1) ) / SHOW ERRORS; Prompt Type STRINGTABLETYPE; -- -- STRINGTABLETYPE (Type) -- -- Dependencies: -- STANDARD (Package) -- DROP TYPE DEMO_USER."STRINGTABLETYPE" FORCE; CREATE OR REPLACE TYPE DEMO_USER."STRINGTABLETYPE" AS TABLE OF VARCHAR2 (255) / SHOW ERRORS; Any shell script compatible with ksh on Solaris 8 would be fine. Thanks, Rajan |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|