home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 98 / Skunkware 98.iso / osr5 / sco / scripts / linerec < prev    next >
Encoding:
Text File  |  1997-08-26  |  1.1 KB  |  32 lines

  1. :
  2. # @(#) linerec.sh 1.0 92/02/16
  3. # 91/09/13 john h. dubois iii (john@armory.com)
  4. # 91/10/28 changed name to linerec
  5. # 92/02/16 added help
  6.  
  7. if [ "$1" = -h ]; then
  8.     echo \
  9. "$0: concatenate lines into records.
  10. Usage: $0 [filename ...]
  11. $0 reads files consisting of records, concatenates each record
  12. into a single line, and writes each line onto the standard output.
  13. Records consist of lines.  A record is continued onto the next line by
  14. ending it with a \, optionally followed by spaces or tabs.
  15. The continuatation \, along with any following spaces and tabs,
  16. is converted into a space in the output."
  17.     exit 0
  18. fi
  19.  
  20. # Read a line.  
  21. # If the line is continued 
  22. # (it ends with a \, possibly followed by spaces and tabs),
  23. # then append the next line of input, replace the \, spaces, tabs, and
  24. # embedded newline with a space, and branch to the beginning of the
  25. # script without writing anything.
  26. # If the line is not continued, the take the default sed action 
  27. # (write the pattern space, delete it, read the next line, and go to
  28. # the beginning of the script).
  29. sed ':a
  30. /\\[     ]*$/{N;s/\\[     ]*\n/ /;b a
  31. }' "$@"
  32.