Solved

Delete Blank Lines From A File

Posted on 2011-09-14
9
401 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
  • 5
  • 3
9 Comments
 
LVL 76

Expert Comment

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

Expert Comment

by:jackiechen858
Comment Utility
grep -v "^\s*$"  filename

can remove blank line or lines with only spaces.
0
 

Author Comment

by:xoxomos
Comment Utility
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
Comment Utility
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

Author Comment

by:xoxomos
Comment Utility
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 76

Expert Comment

by:arnold
Comment Utility
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 76

Accepted Solution

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

Author Comment

by:xoxomos
Comment Utility
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
Comment Utility
Mil gracias
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Not able to see disks at the OS level 10 15
UNIX network port 5 45
Shell script errors 10 98
How to clone solaris 10 machine 33 69
I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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…

762 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

Need Help in Real-Time?

Connect with top rated Experts

5 Experts available now in Live!

Get 1:1 Help Now