The NEXT line

The NEXT line

Post by Eric Redo » Sat, 04 Mar 2000 04:00:00



Hello there you script freaks.

I have a little question! I want to get the line that is NEXT to the
line I just grepped... How can I do this in an elegant way (ie. not
proceeding a dirty and heavy awk, for instance)? I'm using Korn Shell.

Any help would be appreciated! Thank you very much!
--

McKessonHBOC France - Tour Horizon           Tl.: +33(0)1.55.91.01.85
52, quai de Dion Bouton - 92800 Puteaux       Fax: +33(0)1.55.91.01.31

 
 
 

The NEXT line

Post by Charles Dem » Sat, 04 Mar 2000 04:00:00




Quote:>Hello there you script freaks.

>I have a little question! I want to get the line that is NEXT to the
>line I just grepped... How can I do this in an elegant way (ie. not
>proceeding a dirty and heavy awk, for instance)? I'm using Korn Shell.

Use GNU's grep.  It has that capability.

Personally I don't think awk is that heavy, or inelegant.

awk '/pattern/ {cnt=NR +1} NR==cnt' infile

prints only the line after the one "grepped"

awk '/pattern/ {cnt=NR +1} NR<=cnt' infile

prints the line "grepped and the next one

Chuck Demas
Needham, Mass.

--
  Eat Healthy    |   _ _   | Nothing would be done at all,

  Die Anyway     |    v    | That no one could find fault with it.


 
 
 

The NEXT line

Post by Eric Redo » Tue, 07 Mar 2000 04:00:00


Hi again!

Charles Demas a crit:

Quote:> Use GNU's grep.  It has that capability.

I didn't know this! But unfortunately I have thr constraint to use only
the commands built in the UNIX of our customers. Anyway, thanks for the
info.

And thank you for the mini-awk script, mine was so dirty I am now ashame
of having written it. Yours is just fine.

I guess it will take some time to me to become more than a
script-newbie.

Anyway! Thank you so much Charles.
--

McKessonHBOC France - Tour Horizon           Tl.: +33(0)1.55.91.01.85
52, quai de Dion Bouton - 92800 Puteaux       Fax: +33(0)1.55.91.01.31

 
 
 

1. select line from file, and then the next line a week later

Let's say I have a file of 5 email addresses. What if I wanted to email
one person on the list, in sequence, every friday.  So on the first
friday, I would email the first person. The following friday I would
email the second person, and so on....

Now I could cron it for friday, but how can I get the script to grab
line one the first time I run it, then grab line 2 the next time I run
it. Is this even possible?

I don't think 'case' can do this for me. I am guessing awk might be
able to, but I am no good at awk.

2. A freezing i386 on net install

3. Search file and print line + next line?

4. Modem Zoom

5. Remove a line if next line is blank

6. calloc error, help needed

7. Search, substitute text on NEXT line, in a stream

8. I need help with dial up connection

9. how to find a unknown string and then the next line with the string

10. awk question -- print from next line

11. Every time i try on untar something it just goes to the next line

12. How to search for string and assign the value on next line to a variable

13. evaluating the next line in awk