Cat file1
--------
----------
SCHEMA.TABLE1
insert-------
update-----
-------------
----------
SCHEMA.TABLE2
insert-------
update-----
-----------
------------
SCHEMA.TABLE3
insert-------
update-----
------------
grep -n SCHEMA > header_file2.txt
1: SCHEMA.TABLE1
25:SCHEMA.TABLE2
30:SCHEMA.TABLE3
I need to print values of each schema content to temp file.
sed -n '1,24p' file1.txt > file.tmp$$
sed -n '25,29p' file1.txt > file.tmp$$
Question is how can I get the start and ending line in the header file.so h that I can use with sed to place each table contents into file.
1: SCHEMA.TABLE1 (1-24)
25:SCHEMA.TABLE2 (25-29)
30:SCHEMA.TABLE3 (30-end)
I have below idea but its kind of making it complex. (syntax may not correct)
1:1:SCHEMA.TABLE1
2:25:SCHEMA.TABLE2
3:30:SCHEMA.TABLE3
start=1
start1=expr `$start+1`
end=expr `head -$start1 file1 |tail-1 |cut-d':' -f2`-1 (24)
sed '1, $end' > tmp
start=2
start1=expr `$start+1`
end=expr`head -3 $start1 |tail-1 |cut-d':' -f2`-1 (29)
sed '1, $end' > tmp
Regards,
Veera