How do you signale EOF after multi-line input?

How do you signale EOF after multi-line input?

Post by Peter Delevory » Fri, 01 Oct 1993 05:14:21



I'm trying to read multiple lines into a variable - How can I have ctrl-D
end the input? Right now I end input by typing ctrl-v-d.

(Part of the case statement) :

#!/bin/sh

... stuff

  2 )     echo "Type some notes. To end input, type Ctrl-V-D "
                  while [ "$line"  != ^D   ]
                                  do
                                          read line
                                          echo "$line" >> $notefile
                                  done
                                  ;;

                                  thanks pd

--

 login name:   L1-A                      
 In real life: Peter Delevoryas
 In any other life: a cheap imitation

 
 
 

How do you signale EOF after multi-line input?

Post by Spencer S » Fri, 01 Oct 1993 14:20:01



Quote:>I'm trying to read multiple lines into a variable - How can I have ctrl-D
>end the input? Right now I end input by typing ctrl-v-d.

>(Part of the case statement) :

>#!/bin/sh

>... stuff

>  2 )     echo "Type some notes. To end input, type Ctrl-V-D "
>              while [ "$line"  != ^D   ]
>                              do
>                                      read line
>                                      echo "$line" >> $notefile
>                              done
>                              ;;

   2 )     echo "Type some notes.  To end input, type Ctrl-D "
           cat >> $notefile
           ;;

 
 
 

1. Q: multi-line input and hold space in SED

I need some help with a sed script. I've read the O&A  "sed and awk" book
and found an example on page 123 that almost does exacly what I want but
not quite.

Given an input file of format:

    REC-TAG
      lineofstuff
      lineofstuff
      lineofstuff
    EOF-REC
    REC_TAG
      lineofstuff
      lineofstuff
      lineofstuff        where each logical record starts with the tag
      lineofstuff        REC-TAG and ends with the tag EOF-TAG and has
      lineofstuff        a variable number of lines in between
      lineofstuff
    EOF-REC
    REC-TAG
      lineofstuff
      lineofstuff
      lineofstuff
      lineofstuff
      lineofstuff
      lineofstuff
      lineofstuff
    EOF-REC
    REC-TAG
      lineofstuff
      lineofstuff
      lineofstuff
    EOF-REC
    ...

I want an output file of the format:

REC-TAG lineofstuff lineofstuff lineofstuff
REC-TAG lineofstuff lineofstuff lineofstuff lineofstuff lineofstuff lineofstuff
REC-TAG lineofstuff lineofstuff lineofstuff lineofstuff lineofstuff lineofstuff lineofstuff
REC-TAG lineofstuff lineofstuff lineofstuff
..

I've been using a script like this:

   /REC-TAG/!{
       H
       d
      }
   /REC-TAG/{
       x
       s/\n//
       G
      }

The first part, which collects physical lines in the hold space until
a EOF-TAG is read works great. I can't seem to come up with a method
to not append the EOF-TAG to the hold space prior to output nor clear
the pattern space without popping to top of the script.

Help! TIA.

Please reply to the following address after removing "antispam" and
reversing "tom" in the following address:


Thanks,

Chris Walters

2. HELP: NIS+ mess

3. Anyone doing EQL or any other Multi-Line PPP?

4. sed: how do i do this?

5. converting multi-line records to single line record

6. Porting to Linux

7. extract a line from multi-line variable

8. need fdisk v2.8 But where do I find it??

9. How to change one part on a multi-column, multi-line

10. ? multi home + multi cgi, multi email, multi log, multi support

11. Multi-line Banners using ftpd and rlogind

12. Multi-line shell commands ?

13. IP-IP tunneling and multi-line PPP?