some shell script babies!! -- anyone knoe the BEST way to read lines from a file into either variables or directly into files?<br><br>Basically, i'm creating an output from a file, <br>(eg; karlssuperduperwotsitfile.fle) and placing it into a format. <br>Ready? -- ok, let me explain a little further...<br><br>File:karlssuperduperwotsitfile.fle<br>data:202 COPY MADSTUPH<br> : 8-S*************<br> : Unknown COPY file specified<br> :213 01 FILLER PIC X(32).<br> :217-S**<br> : Preceeding item at this level has zero length<br> : .....................................<br> :<br><br>So, as you can see (yeah, stop laughing, it IS cobol) i need to be able to read in the files as line input, therefor, i can read $1 for line number, and the rest for <br>the error quoted. For line two, the error code (8-S) and the stars can be omitted. and for line three, the output from the compiler of the error in words. Then, it's all just repeated.<br><br>So, i have looked it in these two methods mainly...<br><br><u>Method 1:</u> <br> line_num=1<br> for line in `cat karlssuperduperwotsitfile.fle`<br> do <br> case line_num in<br> 1) line_err=$1<br> line_num=2<br> 2) line_code=$2<br> line_num=3<br> 3) line_explination=$*<br> line_num=1<br> done<br> <i><b>... And the story goes on</b><br> Is line a reserved shell-script word i can use for lines? I have done it before, but cant remember how!</i><br><br>Anyhow, it reads variabe in, <br><br>Another way would be:<br><br>using the wc -l and read commands -- cant remember the syntax off hand, but i think you should get the picture... <br><br>ok, i want to be able to read in LINES AT A TIME, rather than variable wannabees (words) at a time.<br><br>Any help will be greately recieved!!!<br><br>Karl.<br><br><img src= <br><br><i>P.S. this has got to be the biggest post i ever wrote!!</i><br><br> <p> Karl<br><a href=mailto:mc_karl@yahoo.com>mc_karl@yahoo.com</a><br><a href= > </a><br> ~ ~ ~ ~<br>
K A R L<br>
~ ~ ~ ~
K A R L<br>
~ ~ ~ ~