Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

removing lines from an output file

Status
Not open for further replies.

billy1

Technical User
Sep 16, 2002
73
IE
we have a script that runs a sql sqript generating an output. 'spool' which can be used within the sql script to capture the output doesn't seem to work for some reason.
But we can send the output to an output text file.
The only problem is there are the usual oracle statements as you connect to sqlplus appearing in the output file.
So basically what I want to do is remove the top say 10 lines and the bottom five lines from the output file.
Anyone got any ideas ?
 
Not being by a computer atm here is a basic gist of how to do it

do a wc -l to get number of lines in file
let head_lines=lines_in_file-5
let tail_lines=head_lines-10
head -$head_lines filename|tail -$tail_lines > new_file

Alternatively, perhaps you could just grep out the lines with ORA- in them

Dave
 
hi,

try this
delete 1,10 lines
then go to end of file and delete 5 lines

cat origfile | sed -e '1,10d' | sed -e :a -e '$d;N;2,5ba' -e
'P;D' > newfile

HTH
 
by the way , how have you got your spool set in your sql script , is it like this

spool /tmp/filename.txt

commands


spool off

hth
 
Thats great thanks. It works fine.
Yeah I don't know why the spool file doesn't work. Maybe it's because too many scripts are involved. one script has to 'su - oracle' and then run the sql script which sets off the spool (as you've indicated). The spool works ok if I'm signed in as oracle just running the sql script so.....?



 
Billy, this probably won't help, but I know I've had problems in the past with the spool command because it defaulted to put the file somewhere other than where I expected. Are you sure that the file isn't being created? Try a find . -name <spool_filename> -print from a top-level directory to check that it isn't being placed somewhere else. Cheers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top