Hello,
I need to copy text between a start and an end pattern from one file to another.
For example,
Lets say I have a file with the following content:
hello world1
hello world2
hello world3
hello world4
hello world5
beep
I need a shell script that can produce the following file:
hello world2
hello world3
hello world4
hello world5
beep
I do not know the line numbers for the range I want to copy, I just want to copy from the occurrence of 'hello world2' to the occurrence of 'hello world5'+1 line
In case you are wondering what I am trying to do here, I want to run a thread dump on my machine using kill -3 <pid> but the output of this goes to standard output which in my case is directed to the jboss out file which has a lot of other logs in it. So I want to run this script to extract the thread dumps into a separate file once the kill has been executed. Needless to say, there might be more than one thread dumps in the jboss.out file
Any help will be appreciated.
Thank you
Configuration: Linux Firefox 3.5
The simplest way, if your input file is at /folder/somefile.txt,
|
Hi, jp@MDK:~/tmpfs ssh$ cat plop
hello world1
hello world2
hello world3
hello world4
hello world5
beep
jp@MDK:~/tmpfs ssh$ sed -n '/world2/{:z;N;/world5$/!bz;N;p}' plop > bar
jp@MDK:~/tmpfs ssh$ cat bar
hello world2
hello world3
hello world4
hello world5
beep
jp@MDK:~/tmpfs ssh$;-))
$ man woman Il n'y a pas de page de manuel pour woman. |