while ((getline variable <"file") > 0)

while ((getline variable <"file") > 0)

Post by JW Paso » Thu, 21 Feb 2002 03:47:48



Who can help me out?

I need a script that reads every line in "file" and write that to variable.
The variable should then be processed. After processing the last variable
the script should terminate itself.

The awk command in the subject box should do exactly this. At least that's
what the
books tell me. My script doesn't work. I don't even get the following script
to work:

nawk '{

while ((getline  < "file") > 0)
print

Quote:}'

The script is supposed to print all lines of "file". I tried it on my linux
machine and at work
on solaris 2.6
Who can help this starter?
 
 
 

while ((getline variable <"file") > 0)

Post by Mosh » Thu, 21 Feb 2002 03:43:23


JW Pasop had nothing better to do than to say:

Quote:> I need a script that reads every line in "file" and write that to variable.
> The variable should then be processed. After processing the last variable
> the script should terminate itself.

while read line; do
    something with "$line"
done < file

Moshe

--
*** SPAM BLOCK: Remove bra before replying! ***
Moshe Jacobson :: http://runslinux.net :: moshe at runslinux dot net

 
 
 

while ((getline variable <"file") > 0)

Post by Chris F.A. Johnso » Thu, 21 Feb 2002 06:03:29



> Who can help me out?

> I need a script that reads every line in "file" and write that to variable.
> The variable should then be processed. After processing the last variable
> the script should terminate itself.

> The awk command in the subject box should do exactly this. At least that's
> what the
> books tell me. My script doesn't work. I don't even get the following script
> to work:

> nawk '{

> while ((getline  < "file") > 0)
> print

> }'

> The script is supposed to print all lines of "file". I tried it on my linux
> machine and at work
> on solaris 2.6
> Who can help this starter?

        nawk 'NR' file

--
    Chris F.A. Johnson                        http://cfaj.freeshell.org
    ===================================================================
    My code (if any) in this post is copyright 2002, Chris F.A. Johnson
    and may be copied under the terms of the GNU General Public License

 
 
 

while ((getline variable <"file") > 0)

Post by Charles Dem » Thu, 21 Feb 2002 06:36:49





>> Who can help me out?

>> I need a script that reads every line in "file" and write that to variable.
>> The variable should then be processed. After processing the last variable
>> the script should terminate itself.

>> The awk command in the subject box should do exactly this. At least that's
>> what the
>> books tell me. My script doesn't work. I don't even get the following script
>> to work:

>> nawk '{

>> while ((getline  < "file") > 0)
>> print

>> }'

>> The script is supposed to print all lines of "file". I tried it on my linux
>> machine and at work
>> on solaris 2.6
>> Who can help this starter?

>    nawk 'NR' file

        nawk '1' file

Chuck Demas

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

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

 
 
 

1. (<><>)*Linux*Screen*Difficulties*(<><>)

There is none. Its a matter of preference.

Edit /etc/X11/XF86Config file by putting a # in front of the line that starts
with the word "virtual".

--
All the best,
Shawn Smith  !UNT Proud!
My Resume http://sites.netscape.net/shawnspad/shawn_smith_resume.htm
My freeware: http://sites.netscape.net/shawnspad

2. csh:how to 'pre-source; something

3. >>>Compiling 2.0 problem: "asm86: Command not found" <<<

4. Linux dialin ISDN server (>=3-BRI)

5. <font color="blue"><B>kmail</B></font> question

6. Linux Junior

7. <font color="blue"><B>modemblaster</B></font>

8. Localization with Solaris and Windows (EUC/SJIS).

9. Type "(", ")" and "{", "}" in X...

10. "sar -f <file>" fails with "sar: malloc failed"

11. "getline < file" in awk

12. is file<<"STRING"<<endl.atomic operation.

13. Is file<<"Some string"<<endl is an atomic operation.