0

I am not a programmer. I know a couple of unix/linux commands (do not know awk).

I need to extract text lines that contain a specific sequence of string characters.

Here is my example:

strings -f -n30 i15app.fmb | grep -i getApplQuota

The output for this is :

i15app.fmb: v_return := stud.i36pkg.getApplQuota(:b6.igxquota,

I need to also extract a number of lines of text after this result.

For anybody that is wondering, I need to extract the lines from an Oracle forms program and do not have access to Forms Developer.

Is this possible?

Regards,

Phlip

3
  • "I need to also extract a number of lines of text after this result." Does it mean that you need to display number of lines where the string appeared? (1) or you need to know how many lines of text appeared after each occurrence of text (2)? (1) is easy strings -f -n30 i15app.fmb | grep -i getApplQuota |wc -l (2) looks pretty much complicated Commented Oct 11, 2016 at 12:36
  • Please edit Q to include small sample (even if fake) input and expected output! Good luck. Commented Oct 11, 2016 at 12:47
  • Hi, Thanks for the response; the answer to your question, I need to extract a number of lines after the line that contains the text irrespective if those lines contain the original text: In my example the string "i15app.fmb: v_return := stud.i36pkg.getApplQuota(:b6.igxquota," but I also want 5/10/20 lines extracted that comes directly after this line irrespective of those 5/10/20 lines contains the text that I am searching for, Regards, Phlip Commented Oct 12, 2016 at 13:17

1 Answer 1

2

try this;

strings -f -n30 i15app.fmb | grep -i getApplQuota && strings -f -n30 i15app.fmb | grep -ic getApplQuota

grep -c will print the total lines matched

Eg;

user@host$ strings -f -n30 i15app.fmb | grep -i getApplQuota && strings -f -n30 i15app.fmb | grep -ic getApplQuota
i15app.fmb: i15app.fmb: v_return := stud.i36pkg.getApplQuota(:b6.igxquota,
i15app.fmb: i15app.fmb: v_return := stud.i36pkg.getApplQuota(:b6.igxquota,
i15app.fmb: i15app.fmb: v_return := stud.i36pkg.getApplQuota(:b6.igxquota,
i15app.fmb: i15app.fmb: v_return := stud.i36pkg.getApplQuota(:b6.igxquota,
i15app.fmb: i15app.fmb: v_return := stud.i36pkg.getApplQuota(:b6.igxquota,
i15app.fmb: i15app.fmb: v_return := stud.i36pkg.getApplQuota(:b6.igxquota,
i15app.fmb: i15app.fmb: v_return := stud.i36pkg.getApplQuota(:b6.igxquota,
7
Sign up to request clarification or add additional context in comments.

3 Comments

Hallo Thanks for responding. My original command of strings -f -n30 i15app.fmb | grep -i getApplQuota returns all the lines containing the text that I am searching for. As I have responded to @Anil_M above, I also want to extract a number of lines directly following the line in which the text was found irrespective if those lines contain my search text. I thus expects my command strings -f -n30 i15app.fmb | grep -i getApplQuota to return some thing like
i15app.fmb: v_return := stud.i36pkg.getApplQuota(:b6.igxquota, i15app.fmb: (:b6.igxqual, i15app.fmb: (:b6.igxitem, i15app.fmb: (:b6.igxanother_line,
Hi, Sorry, I could not get the formatting the expected output in several lines. How do you do that?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.