Shell scripts: variable assignment within read loops

Giorgos Keramidas keramida at ceid.upatras.gr
Mon Aug 18 12:55:55 UTC 2008


On Mon, 18 Aug 2008 14:33:05 +0200, Polytropon <freebsd at edvax.de> wrote:
> As I thought while reading your message, awk seems to be
> a good solution. Just a note:
>
> On Mon, 18 Aug 2008 06:29:03 +0300, Giorgos Keramidas <keramida at ceid.upatras.gr> wrote:
>> Would you
>> be ok with an awk(1) script instead of /bin/sh?  It tends to be nicer
>> for this sort of thing, i.e.:
>>
>> [...]
>> $ netstat -nibd -f inet | awk -f david.awk
>
> You could start your awk skript with
>
> 	#!/usr/bin/awk
>
> and give it +x attribute, as well as adding the desired source
> command "netstat -nibd -f inet" to the script, using awk's system()
> function, so you can start it more easily or use it in combination
> with other commands.
>
> 	% ./netstuff.awk

That's an option, but piping *to* awk may be slightly trickier then.




More information about the freebsd-questions mailing list