Solved

Delete Blank Lines From A File

Posted on 2011-09-14
9
409 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 78

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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 78

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 78

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Java core in Solaris 10 1 307
ftpcommand 2 73
Cygwin VIM in WIndows 2007: Unable to copy text to Windows 10 74
Image not there 4 63
This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
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…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

713 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