Solved

Delete Blank Lines From A File

Posted on 2011-09-14
9
418 Views
Last Modified: 2012-05-12
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
Comment
Question by:xoxomos
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
9 Comments
 
LVL 79

Expert Comment

by:arnold
ID: 36540110
Is the line really blank or is it spaces filled?
cat filename | egrep -v '^\s+\$'  
0
 
LVL 7

Expert Comment

by:jackiechen858
ID: 36543884
grep -v "^\s*$"  filename

can remove blank line or lines with only spaces.
0
 

Author Comment

by:xoxomos
ID: 36544073
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.

 

Author Comment

by:xoxomos
ID: 36544091
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
 

Author Comment

by:xoxomos
ID: 36544094
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
 
LVL 79

Expert Comment

by:arnold
ID: 36544206
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
 
LVL 79

Accepted Solution

by:
arnold earned 300 total points
ID: 36544351
try
cat create_user.sql | egrep -i '[a-z0-9\-]'
 
0
 

Author Comment

by:xoxomos
ID: 36544746
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
 

Author Closing Comment

by:xoxomos
ID: 36544751
Mil gracias
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Suggested Courses

622 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question