|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
I am writing a ksh script and trying to extract some lines that come
after a particular line. Following is my sample file ================================================== ======================= Number of students in class are 50 Number of students with GPA>3.0 are 18 Some more lines Last Name First Name Class Date GPA -------------------------------------------------------------------------------------------------------------------------------------- James Dave xxxx xxxx xxxxxx xxxxx xxxxx xxxxx xxxxx xxxxxxxx xxxxxxx xxxxxxxxxx xxxxx xxxxxxxxxx xxxxxxxxxx Professor: Dr. XYZ School:XYZ ================================================== ========================== I want all the lines that are below Last Name,First Name, Class, Date,GPA heading but before Professor r. XYZ.Any ? Regards, |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
rachit7@gmail.com wrote:
> I am writing a ksh script and trying to extract some lines that come > after a particular line. Following is my sample file > ================================================== ======================= > Number of students in class are 50 > Number of students with GPA>3.0 are 18 > Some more lines > > Last Name First Name > Class Date GPA > -------------------------------------------------------------------------------------------------------------------------------------- > James Dave > xxxx xxxx xxxxxx > xxxxx xxxxx > xxxxx xxxxx xxxxxxxx > xxxxxxx xxxxxxxxxx > xxxxx xxxxxxxxxx xxxxxxxxxx > > Professor: Dr. XYZ > School:XYZ > ================================================== ========================== > > I want all the lines that are below Last Name,First Name, Class, > Date,GPA heading but before Professor r. XYZ.Assuming there are some line-breaks in the above posting that are non-existent in your actual data. You can take the dashes and the empty line as separator... awk '/^------------------/,/^$/' your-data-file If the assumption is not valid, come back and ask. Janis > > Any ? > Regards, > |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
On Jul 16, 8:50 pm, Janis Papanagnou <Janis_Papanag...@hotmail.com>
wrote: > rach...@gmail.com wrote: > > I am writing a ksh script and trying to extract some lines that come > > after a particular line. Following is my sample file > > ================================================== ======================= > > Number of students in class are 50 > > Number of students with GPA>3.0 are 18 > > Some more lines > > > Last Name First Name > > Class Date GPA > > -------------------------------------------------------------------------------------------------------------------------------------- > > James Dave > > xxxx xxxx xxxxxx > > xxxxx xxxxx > > xxxxx xxxxx xxxxxxxx > > xxxxxxx xxxxxxxxxx > > xxxxx xxxxxxxxxx xxxxxxxxxx > > > Professor: Dr. XYZ > > School:XYZ > > ================================================== ========================== > > > I want all the lines that are below Last Name,First Name, Class, > > Date,GPA heading but before Professor r. XYZ.> > Assuming there are some line-breaks in the above posting that are > non-existent in your actual data. > > You can take the dashes and the empty line as separator... > > awk '/^------------------/,/^$/' your-data-file > > If the assumption is not valid, come back and ask. > > Janis > > > > > Any ? > > Regards, Thanks Janis It works. I didn't know that one can give two line saprators in awk to limit the contents of an input file. Thanks again. I have one more question about system() function in awk but I will ask it in a new post. Regards, Rachit. |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
On Jul 17, 8:05 am, rach...@gmail.com wrote:
> I am writing a ksh script and trying to extract some lines that come > after a particular line. Following is my sample file > ================================================== ======================= > Number of students in class are 50 > Number of students with GPA>3.0 are 18 > Some more lines > > Last Name First Name > Class Date GPA > -------------------------------------------------------------------------------------------------------------------------------------- > James Dave > xxxx xxxx xxxxxx > xxxxx xxxxx > xxxxx xxxxx xxxxxxxx > xxxxxxx xxxxxxxxxx > xxxxx xxxxxxxxxx xxxxxxxxxx > > Professor: Dr. XYZ > School:XYZ > ================================================== ========================== > > I want all the lines that are below Last Name,First Name, Class, > Date,GPA heading but before Professor r. XYZ.> > Any ? > Regards, awk 'BEGIN{RS="";FS="[-]+"}{ print $2}' "file" |
|
![]() |
| Outils de la discussion | |
|
|