Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 423
  • Last Modified:

Delete Blank Lines From A File

Trying to delete blank lines from an Oracle SQLFILE.  I've tried sed '/^$/d' filename and going into vi then : /^$/d.  Neither works.
set list
-- new object type path is: DATABASE_EXPORT/SCHEMA/TABLE/GRANT/OWNER_GRANT/OBJECT_GRANT$
-- CONNECT OUTLN$
GRANT SELECT ON "OUTLN"."OL$" TO "SELECT_CATALOG_ROLE";$
 $
GRANT SELECT ON "OUTLN"."OL$HINTS" TO "SELECT_CATALOG_ROLE";$
 $
-- CONNECT SYSTEM$
GRANT SELECT ON "SYSTEM"."DEF$_AQCALL" TO "SYS" WITH GRANT OPTION;$
 $
GRANT SELECT ON "SYSTEM"."DEF$_ERROR" TO "SYS" WITH GRANT OPTION;$
 $
GRANT SELECT ON "SYSTEM"."DEF$_DESTINATION" TO "SYS" WITH GRANT OPTION;$
 $
GRANT SELECT ON "SYSTEM"."DEF$_CALLDEST" TO "SYS" WITH GRANT OPTION;$
 $
GRANT SELECT ON "SYSTEM"."DEF$_LOB" TO "SYS" WITH GRANT OPTION;$
 $
GRANT DELETE ON "SYSTEM"."DEF$_TEMP$LOB" TO "SYS" WITH GRANT OPTION;$
:set list
0
xoxomos
Asked:
xoxomos
  • 5
  • 3
1 Solution
 
arnoldCommented:
Is the line really blank or is it spaces filled?
cat filename | egrep -v '^\s+\$'  
0
 
jackiechen858Commented:
grep -v "^\s*$"  filename

can remove blank line or lines with only spaces.
0
 
xoxomosAuthor Commented:
Blank lines remain
oracle@bb7b:/u05/datapump_directory$ grep -v "^\s*$" create_user.sql
-- new object type path is: DATABASE_EXPORT/SYS_USER/USER
 ALTER USER "SYS" IDENTIFIED BY VALUES 'BBFEC2ABA14349B0'
      TEMPORARY TABLESPACE "TEMP";
 
-- new object type path is: DATABASE_EXPORT/SCHEMA/USER
 ALTER USER "SYSTEM" IDENTIFIED BY VALUES 'E3C232DAD21E66AE'
      DEFAULT TABLESPACE "TOOLS"
      TEMPORARY TABLESPACE "TEMP";
 
 CREATE USER "OUTLN" IDENTIFIED BY VALUES '4A3BA55E08595C81'
      TEMPORARY TABLESPACE "TEMP";
 
 CREATE USER "TRACESVR" IDENTIFIED BY VALUES 'F9DA8977092B7B81'
      DEFAULT TABLESPACE "SMALL_DEFAULT"
      TEMPORARY TABLESPACE "TEMP";
 
 CREATE USER "BBADMIN" IDENTIFIED BY VALUES '35DE13A3ED9CDD95'
      DEFAULT TABLESPACE "BBADMIN_DATA"
      TEMPORARY TABLESPACE "TEMP";
 
 CREATE USER "BB_BB60_STATS" IDENTIFIED BY VALUES 'DD5B4DC833EE258E'
      DEFAULT TABLESPACE "BB_BB60_STATS_DATA"
      TEMPORARY TABLESPACE "TEMP";
 
 CREATE USER "BB_BB60" IDENTIFIED BY VALUES '7EFB15396EAF1168'
      DEFAULT TABLESPACE "BB_BB60_DATA"
      TEMPORARY TABLESPACE "TEMP";
 
 CREATE USER "CSUH_CUSTOM" IDENTIFIED BY VALUES 'E038316871F962A3'
      DEFAULT TABLESPACE "USERS"
      TEMPORARY TABLESPACE "TEMP";
 
 CREATE USER "TOAD" IDENTIFIED BY VALUES '4759257F78A8B5A3'
      DEFAULT TABLESPACE "USERS"
      TEMPORARY TABLESPACE "TEMP";
 
 CREATE USER "MONITOR" IDENTIFIED BY VALUES 'C15C7CCC01A60009'
      DEFAULT TABLESPACE "USERS"
      TEMPORARY TABLESPACE "TEMP";
 
 CREATE USER "BBUSER" IDENTIFIED BY VALUES '80D18B7604314C8E'
      DEFAULT TABLESPACE "USERS"
      TEMPORARY TABLESPACE "TEMP";
 
 CREATE USER "CMS_FILES_USERS" IDENTIFIED BY VALUES '5847C9D3918C97A2'
      DEFAULT TABLESPACE "CMS_FILES_USERS_DATA"
      TEMPORARY TABLESPACE "TEMP";
 
 CREATE USER "CMS_FILES_ORGS" IDENTIFIED BY VALUES 'AFB576C50494B4C1'
      DEFAULT TABLESPACE "CMS_FILES_ORGS_DATA"
      TEMPORARY TABLESPACE "TEMP";
 
 CREATE USER "CMS_FILES_LIBRARY" IDENTIFIED BY VALUES '7AEB5FC2E127D8C0'
      DEFAULT TABLESPACE "CMS_FILES_LIBRARY_DATA"
      TEMPORARY TABLESPACE "TEMP";
 
 CREATE USER "CMS_FILES_INST" IDENTIFIED BY VALUES '068EFD7044613CA2'
      DEFAULT TABLESPACE "CMS_FILES_INST_DATA"
      TEMPORARY TABLESPACE "TEMP";
 
 CREATE USER "CMS_FILES_COURSES" IDENTIFIED BY VALUES 'F9A622520FAD900B'
      DEFAULT TABLESPACE "CMS_FILES_COURSES_DATA"
      TEMPORARY TABLESPACE "TEMP";
 
 CREATE USER "CMS" IDENTIFIED BY VALUES 'C64584543210EBE1'
      DEFAULT TABLESPACE "CMS_DATA"
      TEMPORARY TABLESPACE "TEMP";
 
 CREATE USER "TSMSYS" IDENTIFIED BY VALUES '3DF26A8B17D0F29F'
      DEFAULT TABLESPACE "SMALL_DEFAULT"
      TEMPORARY TABLESPACE "TEMP"
      PASSWORD EXPIRE
      ACCOUNT LOCK;
 
 CREATE USER "BB_BB60_REPORT" IDENTIFIED BY VALUES 'F380EA59E2ABA7AE'
      DEFAULT TABLESPACE "BB_BB60_DATA"
      TEMPORARY TABLESPACE "TEMP";
 
 CREATE USER "CMS_DOC" IDENTIFIED BY VALUES '43F8F151C0F109AB'
      DEFAULT TABLESPACE "CMS_DOC_DATA"
      TEMPORARY TABLESPACE "TEMP";
 
 CREATE USER "SYSMAN" IDENTIFIED BY VALUES '921843AF2EA8AFA2'
      DEFAULT TABLESPACE "SYSAUX"
      TEMPORARY TABLESPACE "TEMP";
 
 CREATE USER "MGMT_VIEW" IDENTIFIED BY VALUES 'B2E0DCB0078F8133'
      TEMPORARY TABLESPACE "TEMP";
oracle@bb7b:/u05/datapump_directory$
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
xoxomosAuthor Commented:
Blank lines remain
oracle@bb7b:/u05/datapump_directory$ grep -v "^\s*$" create_user.sql
-- new object type path is: DATABASE_EXPORT/SYS_USER/USER
 ALTER USER "SYS" IDENTIFIED BY VALUES 'BBFEC2ABA14349B0'
      TEMPORARY TABLESPACE "TEMP";
 
-- new object type path is: DATABASE_EXPORT/SCHEMA/USER
 ALTER USER "SYSTEM" IDENTIFIED BY VALUES 'E3C232DAD21E66AE'
      DEFAULT TABLESPACE "TOOLS"
      TEMPORARY TABLESPACE "TEMP";
 
 CREATE USER "OUTLN" IDENTIFIED BY VALUES '4A3BA55E08595C81'
      TEMPORARY TABLESPACE "TEMP";
 
 CREATE USER "TRACESVR" IDENTIFIED BY VALUES 'F9DA8977092B7B81'
      DEFAULT TABLESPACE "SMALL_DEFAULT"
      TEMPORARY TABLESPACE "TEMP";
 
 CREATE USER "BBADMIN" IDENTIFIED BY VALUES '35DE13A3ED9CDD95'
      DEFAULT TABLESPACE "BBADMIN_DATA"
      TEMPORARY TABLESPACE "TEMP";
 
 CREATE USER "BB_BB60_STATS" IDENTIFIED BY VALUES 'DD5B4DC833EE258E'
      DEFAULT TABLESPACE "BB_BB60_STATS_DATA"
      TEMPORARY TABLESPACE "TEMP";
 
 CREATE USER "BB_BB60" IDENTIFIED BY VALUES '7EFB15396EAF1168'
      DEFAULT TABLESPACE "BB_BB60_DATA"
      TEMPORARY TABLESPACE "TEMP";
 
 CREATE USER "CSUH_CUSTOM" IDENTIFIED BY VALUES 'E038316871F962A3'
      DEFAULT TABLESPACE "USERS"
      TEMPORARY TABLESPACE "TEMP";
 
 CREATE USER "TOAD" IDENTIFIED BY VALUES '4759257F78A8B5A3'
      DEFAULT TABLESPACE "USERS"
      TEMPORARY TABLESPACE "TEMP";
 
 CREATE USER "MONITOR" IDENTIFIED BY VALUES 'C15C7CCC01A60009'
      DEFAULT TABLESPACE "USERS"
      TEMPORARY TABLESPACE "TEMP";
 
 CREATE USER "BBUSER" IDENTIFIED BY VALUES '80D18B7604314C8E'
      DEFAULT TABLESPACE "USERS"
      TEMPORARY TABLESPACE "TEMP";
 
 CREATE USER "CMS_FILES_USERS" IDENTIFIED BY VALUES '5847C9D3918C97A2'
      DEFAULT TABLESPACE "CMS_FILES_USERS_DATA"
      TEMPORARY TABLESPACE "TEMP";
 
 CREATE USER "CMS_FILES_ORGS" IDENTIFIED BY VALUES 'AFB576C50494B4C1'
      DEFAULT TABLESPACE "CMS_FILES_ORGS_DATA"
      TEMPORARY TABLESPACE "TEMP";
 
 CREATE USER "CMS_FILES_LIBRARY" IDENTIFIED BY VALUES '7AEB5FC2E127D8C0'
      DEFAULT TABLESPACE "CMS_FILES_LIBRARY_DATA"
      TEMPORARY TABLESPACE "TEMP";
 
 CREATE USER "CMS_FILES_INST" IDENTIFIED BY VALUES '068EFD7044613CA2'
      DEFAULT TABLESPACE "CMS_FILES_INST_DATA"
      TEMPORARY TABLESPACE "TEMP";
 
 CREATE USER "CMS_FILES_COURSES" IDENTIFIED BY VALUES 'F9A622520FAD900B'
      DEFAULT TABLESPACE "CMS_FILES_COURSES_DATA"
      TEMPORARY TABLESPACE "TEMP";
 
 CREATE USER "CMS" IDENTIFIED BY VALUES 'C64584543210EBE1'
      DEFAULT TABLESPACE "CMS_DATA"
      TEMPORARY TABLESPACE "TEMP";
 
 CREATE USER "TSMSYS" IDENTIFIED BY VALUES '3DF26A8B17D0F29F'
      DEFAULT TABLESPACE "SMALL_DEFAULT"
      TEMPORARY TABLESPACE "TEMP"
      PASSWORD EXPIRE
      ACCOUNT LOCK;
 
 CREATE USER "BB_BB60_REPORT" IDENTIFIED BY VALUES 'F380EA59E2ABA7AE'
      DEFAULT TABLESPACE "BB_BB60_DATA"
      TEMPORARY TABLESPACE "TEMP";
 
 CREATE USER "CMS_DOC" IDENTIFIED BY VALUES '43F8F151C0F109AB'
      DEFAULT TABLESPACE "CMS_DOC_DATA"
      TEMPORARY TABLESPACE "TEMP";
 
 CREATE USER "SYSMAN" IDENTIFIED BY VALUES '921843AF2EA8AFA2'
      DEFAULT TABLESPACE "SYSAUX"
      TEMPORARY TABLESPACE "TEMP";
 
 CREATE USER "MGMT_VIEW" IDENTIFIED BY VALUES 'B2E0DCB0078F8133'
      TEMPORARY TABLESPACE "TEMP";
oracle@bb7b:/u05/datapump_directory$
0
 
xoxomosAuthor Commented:
racle@bb7b:/u05/datapump_directory$ cat create_user.sql  | egrep -v '^\s+\$'  
-- new object type path is: DATABASE_EXPORT/SYS_USER/USER
 ALTER USER "SYS" IDENTIFIED BY VALUES 'BBFEC2ABA14349B0'
      TEMPORARY TABLESPACE "TEMP";
 
-- new object type path is: DATABASE_EXPORT/SCHEMA/USER
 ALTER USER "SYSTEM" IDENTIFIED BY VALUES 'E3C232DAD21E66AE'
      DEFAULT TABLESPACE "TOOLS"
      TEMPORARY TABLESPACE "TEMP";
 
 CREATE USER "OUTLN" IDENTIFIED BY VALUES '4A3BA55E08595C81'
      TEMPORARY TABLESPACE "TEMP";
 
 CREATE USER "TRACESVR" IDENTIFIED BY VALUES 'F9DA8977092B7B81'
      DEFAULT TABLESPACE "SMALL_DEFAULT"
      TEMPORARY TABLESPACE "TEMP";
 
 CREATE USER "BBADMIN" IDENTIFIED BY VALUES '35DE13A3ED9CDD95'
      DEFAULT TABLESPACE "BBADMIN_DATA"
      TEMPORARY TABLESPACE "TEMP";
 
 CREATE USER "BB_BB60_STATS" IDENTIFIED BY VALUES 'DD5B4DC833EE258E'
      DEFAULT TABLESPACE "BB_BB60_STATS_DATA"
      TEMPORARY TABLESPACE "TEMP";
 
 CREATE USER "BB_BB60" IDENTIFIED BY VALUES '7EFB15396EAF1168'
      DEFAULT TABLESPACE "BB_BB60_DATA"
      TEMPORARY TABLESPACE "TEMP";
 
 CREATE USER "CSUH_CUSTOM" IDENTIFIED BY VALUES 'E038316871F962A3'
      DEFAULT TABLESPACE "USERS"
      TEMPORARY TABLESPACE "TEMP";
0
 
arnoldCommented:
The problem is that to exclude something you have to know what is there

What is the issue that the blank lines are causing which leads you to have the need to have them removed??

try cat create_user.sql | grep -i '(alter|default|tablespace|path)'

0
 
arnoldCommented:
try
cat create_user.sql | egrep -i '[a-z0-9\-]'
 
0
 
xoxomosAuthor Commented:
cat create_user.sql | egrep -i '[a-z0-9\-]' > create_users.sql
 :-)  :-)  :-)

Basically i want to use it as a SQL script.  In all there are 800,000+ lines involved.
If I go into SQLPlus and call that as a script it will error out on any blank line between statements.
Thanks
0
 
xoxomosAuthor Commented:
Mil gracias
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now