I have modified and rename the content but just mainly the segment name, I have put some segment name as an example.
In this example, the tablespace name is ABC_XYZXYZ_TXT and it is composed of two datafiles, file 18 and file 14. I am guessing Block 1 is the file header of each datafile hence the segment column is empty for where it is Block 1.
I'll try my best to explain what I am wanting to do. Before I go write a long script for it, I want to know first if maybe I can 'simply' use awk inside the script to search and print a range of lines above and below a given number.
For example, if I do x.ksh 3000, the script should print out something like below based on what's on testfile.txt.
At the moment, I am thinking of reading the file one at a time and comparing the third field to the given argument that is 3000. While it seem easy to print the next 5 records > 3000, I can't think of a way of saving the last 5 that are less than 3000?
I am hoping I can get some advice on how to achieve what I am wanting to do.
I have a few to questions pose in response first:-
Is this homework/assignment? There are specific forums for these.
What have you tried so far?
What output/errors do you get?
What OS and version are you using?
What are your preferred tools? (C, shell, perl, awk, etc.)
What logical process have you considered? (to help steer us to follow what you are trying to achieve)
Most importantly, What have you tried so far?
I'm not too clear what you intention is, but if you can numerically sort the data (or it already is) and pass it through grep, the -A and/or -B flags may do what you want.
There are probably many ways to achieve most tasks, so giving us an idea of your style and thoughts will help us guide you to an answer most suitable to you so you can adjust it to suit your needs in future.
Until you answer Robin's question about homework, you won't get any further help on this topic. And, with over 200 posts and more than 8 years in this forum, we shouldn't have to repeat the questions that Robin asked. We are happy to help you learn how to use UNIX utilities to do what you need to do, but we are not your unpaid programming staff. Other than needing to use line 2 in your input file to figure out where field boundaries are located, this is can be done with a pretty simple awk script.
So, answer the homework question.
Show us what you've tried to solve this on your own.