Increase the buffer size to read lengthy lines

Hi All,

I am trying to read output from a command. The output format is as follows:

Thursday 13 Mar 2008 Information 
This is sample text
Friday 14 Mar 2008 Warning
This is one more sample text

First line contains informtation (date etc) and the 2nd line contains some information.

The problem is sometimes the 2nd line's length is more and that is being read as two lines in Unix. But i want to read that as one line itself.

Can we increase the line buffer size in Unix?
I hope the question is clear.

Regards,
Ssunda.

Your problem is not "buffer size". If you are using a command which reads one line at a time, it will read even long lines, but if the input is more than one line, it will only read the first line.

Let's rephrase this problem. How do you know when something is more than one line? Because the next line is then not a date stamp. So you can create a simple parser for this format, which recognizes everything up to the next date stamp as one input record.

This is probably best done with a scripting language such as awk or Perl or Python, but just for the sake of argument, here's a quick and dirty solution in shell script:

#!/bin/sh

date=
input=
nl="
"  # yes, that's opening quote, newline, closing quote
while read line; do
  case $line in
    *day\ [0-9][0-9]\ *\ [12][0-9][0-9][0-9]\ *)
      # warning! y3k problem
      # warning! fragile matching, would be better with regex
      # warning! basically untested code anyway
      case $date in '') ;;
        *) echo "Result for '$date'":
	    echo "$input" ;;
      esac
      input=
      date=$line
      ;;
    *)
      input="$input${input:+$nl}$line"
      ;;
  esac
done

# whatever is left at end of file is a result too
echo "Result for '$date'":
echo "$input"

HI era,

Thanx for the reply.
Got your point. But is there anyway that we can increase the buffer size?
In SQL, we use 'set line 200'.. to achieve the same.

Thanks in advance.

Your question is not well-defined. Buffer size of what? What command are you using to read the output? If it has a limit on how long lines it will read, can you find a version which has no such limit?

(For example, the GNU coreutils tools are often better in this regard than whatever equivalent tools shipped with your commercial OS.)