Find a line and copy the next 10 lines
-
Hi Alan
Thank you very much for spending time on my request.I tried for my file, it is not working. It is selecting all the lines.
I want to search with below lines and copy the 10 lines present below to the lines. Similar blocks are there in multiple location in my log fie.
common specific line is “show chassis environment pem” and i gave the regex as “^.show chassis environment pem.\R(.*\R){10}”
It is seclecting all my lines in the log. Few words are common in other lines “show, chassis, environment”.
I tried with only PEM as that is the unique as “^.* pem|.\R(.\R){10}” but not achieving the required one.
Let me know if i miss anything here.
-
@muthuraj-madasamy Your first example has missing asterisks
*
and your second has an or bar|
that is not part of Alan’s solution.Regex machinery cares very little for your intentions, and demands rigid compliance to correct syntax.
I suggest you copy his text, paste, and then carefully replace just the 5 characters
12345
with text you want. -
@neil-schipper
Thank you and belwo is the output. This is a huge log file.^.pem.\R(.*\R){10}
I used above search but still not selecting all the lines. As you see in the below image.
-
@muthuraj-madasamy Hi.
First, remove the check from. matches newline
like in the image Alan provided.Second, I see you used
^.pem.\R(.*\R){10}
. Again, this wrong. What you need is^.*pem.*\R(.*\R){10}
. The dot.
and asterisk*
characters have special meaning to the software that performs regular expression processing; you cannot add/remove them casually. -
This post is deleted! -
This is the output after
-
I don’t want to have to shout but you really need to remove the check from
. matches newline
like in the image Alan providedIt’s in the Search Mode box. See it?
-
@muthuraj-madasamy said in Find a line and copy the next 10 lines:
^.pem.\R(.*\R){10}
I used above search but still not selecting all the lines. As you see in the below image.Hi. You didn’t notice that the expression that appears above is different from what you typed or pasted in, right? It’s missing two asterisks of the original. This is because when you paste text with asterisks in this discussion board, software converts the text to italics so people can make PRETTY TEXT. (The preview pane let’s you see this, but you have to look carefully.)
The way to prevent this is to use one of the two
triple backquote techniques
as described in Please Read Before Posting.Well, I didn’t notice either, and I was wrong to suggest you were using the wrong expression.
-
@neil-schipper said in Find a line and copy the next 10 lines:
Hi Neil
I understood that while responding the search word came default and i didn’t notice that you have taken that as a reference and providing the comments.Can you see the image which i pasted there, in that one i have entered the correct format?
Thanks for spending time with me and i am a new user for notepad++.
-
Thanks a lot. I got your point. the check point is creating trouble. I am able to make it now
once again thanks a lot for helping to fix this
-
@muthuraj-madasamy said in Find a line and copy the next 10 lines:
Can you see the image which i pasted there, in that one i have entered the correct format?
Yes, but I noticed it too late. The text in the image is small and I didn’t think to cross-check.
@muthuraj-madasamy said in Find a line and copy the next 10 lines:
fix this
I’m happy to hear it’s working.
-
Yes Neil…Thanks a lot…
Can you help me any tutorial info for using notepad++? I am new user and not much familiar with these operations.
-
@muthuraj-madasamy said in Find a line and copy the next 10 lines:
any tutorial info for using notepad++
I’m not sure what you are asking for or needing to know, but it is good if you become familiar with these:
https://npp-user-manual.org/docs/preferences
https://npp-user-manual.org/docs/searching/ -
Wow, Neil, thanks for dealing with THAT, and sparing me. :-)
Additional good reference on regular expressions (the technique shown above to solve the problem) is found starting HERE.