[PLUG] bash and awk strangeness
Daniel Herrington
herda05 at gmail.com
Tue Jan 27 18:25:08 UTC 2015
On Tue, Jan 27, 2015 at 10:15 AM, Rich Shepard <rshepard at appl-ecosys.com>
wrote:
> On Tue, 27 Jan 2015, Daniel Herrington wrote:
>
> > host=$(awk '{ print "wtf:" $m }')
>
> Daniel,
>
> Your awk statement begins by printing the string, wtf: and that is why
> you
> see that in the output.
>
> As Paul wrote, show us the input file and we can examine the output
> relative to it.
>
> Regards,
>
> Rich
> _______________________________________________
> PLUG mailing list
> PLUG at lists.pdxlinux.org
> http://lists.pdxlinux.org/mailman/listinfo/plug
>
The file:
foo
bar
baz
bunt
awk seems to be able to read bar in the file before the echo "before
testing:" statement(line 8). Actually, it clearly has to, I just don't
understand why:
Starting script
before testing: foo
foo :: wtf:bar
wtf:baz
wtf:bunt
The code for "before testing: should be read for each run of the for loop,
and should occur before the awk gets called. If I comment out the awk line,
I get the loop behavior I would expect. In fact, I think the for loop is
actually superflous, as the while itself should just loop.
Also:
SunOS svanyc587 5.10 Generic_150400-13 sun4v sparc sun4v
--
Daniel B. Herrington
More information about the PLUG
mailing list