Skip to Main Content

Infrastructure Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

spool files and bash shell commands

VerdiMar 25 2011 — edited Mar 25 2011
Hello,

I'm trying to modify a spooled file.
This is the example:
12:32:46 SQL > spool test1.sql
12:32:52 SQL > select 123 from dual;

       123
----------
       123

Elapsed: 00:00:00.01
12:33:03 SQL > spool off
Then I'm trying to modify the file by removing the last 3 lines:
12:39:20 SQL > host echo $(cat test1.sql | head -$(echo $(( $(cat test1.sql | wc -l) - 3 )))) > newfile.sql
The output from that is:
12:32:52 SQL > select 123 from dual; 123 ---------- 123
As you can see I have lost the "return carriages" in my file test1.sql.
How can I do these modifications (removing lines at the end and from the beginning of the file) and to keep the new lines?
How can I do the above and to receive output like:
12:32:52 SQL > select 123 from dual;

       123
----------
       123
Please, advise?

Oracle Version: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0
Sql Plus Release: 1002000400
Shell: bash
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 22 2011
Added on Mar 25 2011
4 comments
1,972 views